Admin SDK Groups Migration Service

Script to migrate emails to Google Groups discussion archives.

سرویس مهاجرت گروه‌های Admin SDK به شما امکان می‌دهد از API مهاجرت گروه‌های Admin SDK در Google Apps Script استفاده کنید. این API به مدیران دامنه‌های Google Workspace (از جمله فروشندگان) این امکان را می‌دهد که ایمیل‌ها را از پوشه‌های عمومی و لیست‌های توزیع به بایگانی‌های گفتگوی Google Groups منتقل کنند.

This is an advanced service that must be enabled before use .

مرجع

برای اطلاعات دقیق در مورد این سرویس، به مستندات مرجع API مهاجرت گروه‌های SDK مدیریت مراجعه کنید. مانند تمام سرویس‌های پیشرفته در Apps Script، سرویس مهاجرت گروه‌های SDK مدیریت از همان اشیاء، روش‌ها و پارامترهای API عمومی استفاده می‌کند. برای اطلاعات بیشتر، به بخش «نحوه تعیین امضاهای روش» مراجعه کنید.

To report issues and find other support, see the Admin SDK Groups Migration support guide .

کد نمونه

The following sample code uses version 1 of the API.

انتقال ایمیل‌ها از جیمیل به یک گروه گوگل

این نمونه، سه پیام با فرمت RFC 822 را از هر یک از سه رشته آخر در صندوق ورودی Gmail کاربر دریافت می‌کند، یک حباب از محتوای ایمیل (شامل پیوست‌ها) ایجاد می‌کند و آن را در یک گروه گوگل در دامنه قرار می‌دهد.

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;
}