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

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

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

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

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

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

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

ย้ายข้อมูลอีเมลจาก 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;
}