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

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

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

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

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

รหัสตัวอย่าง

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

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

ตัวอย่างนี้ได้รับข้อความที่จัดรูปแบบ RFC 822 จำนวน 3 ข้อความจากชุดข้อความล่าสุด 3 รายการในกล่องจดหมาย Gmail ของผู้ใช้ สร้าง Blob จากเนื้อหาอีเมล (รวมถึงไฟล์แนบ) และแทรกไว้ใน Google Group ในโดเมน

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