บริการย้ายข้อมูลกลุ่ม SDK ผู้ดูแลระบบ

บริการการย้ายข้อมูลกลุ่มของ Admin SDK ช่วยให้คุณใช้ Groups Migration API ของ Admin SDK ใน Apps Script ได้ API นี้ช่วยให้ผู้ดูแลระบบโดเมน Google Workspace (รวมถึงตัวแทนจำหน่าย) สามารถย้ายข้อมูลอีเมลจากโฟลเดอร์สาธารณะและรายชื่อการส่งอีเมลไปยัง ที่เก็บการสนทนาของ Google Groups

ข้อมูลอ้างอิง

ดูข้อมูลโดยละเอียดเกี่ยวกับบริการนี้ได้ในเอกสารอ้างอิงสำหรับ Admin SDK Groups Migration API เช่นเดียวกับบริการขั้นสูงทั้งหมดใน Apps Script บริการย้ายข้อมูลกลุ่มของ Admin SDK จะใช้ออบเจ็กต์ เมธอด และพารามิเตอร์เดียวกันกับ API สาธารณะ ดูข้อมูลเพิ่มเติมได้ที่วิธีกำหนดลายเซ็นของเมธอด

หากต้องการรายงานปัญหาและรับการสนับสนุนอื่นๆ โปรดดูคู่มือการสนับสนุนการย้ายข้อมูลกลุ่ม Admin SDK

โค้ดตัวอย่าง

ตัวอย่างโค้ดด้านล่างใช้ API เวอร์ชัน 1

ย้ายข้อมูลอีเมลจาก Gmail ไปยัง Google Group

ตัวอย่างนี้จะดึงข้อความที่จัดรูปแบบ RFC 822 จำนวน 3 รายการจากเธรดล่าสุด 3 เธรดในกล่องจดหมาย 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;
}