Yönetici SDK'sı Gruplar Taşıma Hizmeti

Yönetici SDK'sı Gruplar Taşıma hizmeti, Apps Script'te Yönetici SDK'sının Gruplar Taşıma API'sini kullanmanıza olanak tanır. Bu API, Google Workspace alanlarının yöneticilerine (bayiler dahil) ortak klasörlerdeki ve dağıtım listelerindeki e-postaları Google Gruplar tartışma arşivlerine taşıma olanağı tanır.

Referans

Bu hizmet hakkında ayrıntılı bilgi için Yönetici SDK'sı Groups Migration API'nin referans belgelerine bakın. Apps Script'teki tüm gelişmiş hizmetler gibi, Admin SDK Grupları Taşıma hizmeti de genel API ile aynı nesneleri, yöntemleri ve parametreleri kullanır. Daha fazla bilgi için Yöntem imzaları nasıl belirlenir? başlıklı makaleyi inceleyin.

Sorunları bildirmek ve diğer destek seçeneklerini öğrenmek için Admin SDK Groups Migration destek kılavuzuna bakın.

Örnek kod

Aşağıdaki örnek kodda API'nin 1. sürümü kullanılmaktadır.

E-postaları Gmail'den Google Grubu'na taşıma

Bu örnek, kullanıcının Gmail gelen kutusundaki son üç ileti dizisinden RFC 822 biçimli üç ileti alır, e-posta içeriğinden (ekler dahil) bir blob oluşturur ve bunu alandaki bir Google Grubu'na ekler.

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