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

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

חומר עזר

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

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

קוד לדוגמה

בקוד לדוגמה שבהמשך משתמשים בגרסה 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;
}