Admin SDK 그룹스 이전 서비스

Admin SDK 그룹스 마이그레이션 서비스를 사용하면 Apps Script에서 Admin SDK의 Groups Migration API를 사용할 수 있습니다. 이 API를 사용하면 리셀러를 포함한 Google Workspace 도메인 관리자는 공개 폴더 및 메일링 리스트에서 Google 그룹스 토론 자료실로 이메일을 이전할 수 있습니다.

참조

이 서비스에 대한 자세한 내용은 Admin SDK Groups Migration API의 참조 문서를 확인하세요. Apps Script의 모든 고급 서비스와 마찬가지로 Admin SDK 그룹스 이전 서비스는 공개 API와 동일한 객체, 메서드, 매개변수를 사용합니다. 자세한 내용은 메서드 서명 확인 방법을 참조하세요.

문제를 신고하고 다른 지원을 받으려면 Admin SDK 그룹 이전 지원 가이드를 참조하세요.

샘플 코드

아래 샘플 코드는 API의 버전 1을 사용합니다.

Gmail에서 Google 그룹으로 이메일 이전하기

이 샘플은 사용자의 Gmail 받은편지함의 최근 세 개 대화목록에서 RFC 822 형식 메일 3개를 받아 이메일 콘텐츠(첨부파일 포함)에서 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;
}