שירות העברת קבוצות ב-SDK של מנהל מערכת

שירות העברת קבוצות ב-Admin SDK מאפשר לכם להשתמש ב-Groups Migration API של Admin SDK ב-Apps Script. ה-API הזה מאפשר לאדמינים של דומיינים ב-Google Workspace (כולל משווקים) להעביר אימיילים מתיקיות ציבוריות ומקבוצות תפוצה לארכיונים של דיונים בקבוצות Google.

חומרי עזר

מידע מפורט על השירות הזה זמין במסמכי העזרה בנושא Admin SDK Groups Migration API. בדומה לכל השירותים המתקדמים ב-Apps Script, שירות העברת הקבוצות של Admin SDK משתמש באותם אובייקטים, שיטות ופרמטרים כמו ממשק ה-API הציבורי. מידע נוסף זמין במאמר איך נקבעות חתימות של שיטות.

כדי לדווח על בעיות ולמצוא תמיכה נוספת, אפשר לעיין במדריך התמיכה בנושא העברת קבוצות Admin SDK.

קוד לדוגמה

בדוגמת הקוד שבהמשך נעשה שימוש בגרסה 1 של ה-API.

העברת אימיילים מ-Gmail לקבוצת Google

בדוגמה הזו מתקבלות שלוש הודעות בפורמט RFC 822 מכל אחד משלושת השרשורים האחרונים בתיבת הדואר הנכנס של המשתמש ב-Gmail, נוצר blob מתוכן האימייל (כולל קבצים מצורפים) והוא מוכנס לקבוצת Google בדומיין.

advanced/adminSDK.gs
/**
 * Gets three RFC822 formatted messages from the each of the latest three
 * threads in the user's Gmail inbox, creates a blob from the email content
 * (including attachments), and inserts it in a Google Group in the domain.
 */
function migrateMessages() {
  // TODO (developer) - Replace groupId value with yours
  const groupId = 'exampleGroup@example.com';
  const messagesToMigrate = getRecentMessagesContent();
  for (const messageContent of messagesToMigrate) {
    const contentBlob = Utilities.newBlob(messageContent, 'message/rfc822');
    AdminGroupsMigration.Archive.insert(groupId, contentBlob);
  }
}

/**
 * Gets a list of recent messages' content from the user's Gmail account.
 * By default, fetches 3 messages from the latest 3 threads.
 *
 * @return {Array} the messages' content.
 */
function getRecentMessagesContent() {
  const NUM_THREADS = 3;
  const NUM_MESSAGES = 3;
  const threads = GmailApp.getInboxThreads(0, NUM_THREADS);
  const messages = GmailApp.getMessagesForThreads(threads);
  const messagesContent = [];
  for (let i = 0; i < messages.length; i++) {
    for (let j = 0; j < NUM_MESSAGES; j++) {
      const message = messages[i][j];
      if (message) {
        messagesContent.push(message.getRawContent());
      }
    }
  }
  return messagesContent;
}