Служба миграции групп Admin SDK
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Служба миграции групп Admin SDK позволяет использовать API миграции групп Admin SDK в Apps Script. Этот API предоставляет администраторам доменов Google Workspace (включая реселлеров) возможность переносить электронные письма из общедоступных папок и списков рассылки в архивы обсуждений Google Групп.
Ссылка
Подробную информацию об этой службе см. в справочной документации по API миграции групп Admin SDK. Как и все расширенные службы в Apps Script, служба миграции групп Admin SDK использует те же объекты, методы и параметры, что и общедоступный API. Подробнее см. в разделе «Как определяются сигнатуры методов» .
Чтобы сообщить о проблемах и найти другую поддержку, см. руководство по поддержке миграции групп Admin SDK .
Пример кода
В примере кода ниже используется версия API 1 .
Перенос писем из Gmail в группу Google
Этот пример получает три сообщения в формате RFC 822 из каждой из трех последних веток в почтовом ящике Gmail пользователя, создает большой двоичный объект из содержимого письма (включая вложения) и вставляет его в группу Google в домене.
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-08-29 UTC.
[null,null,["Последнее обновление: 2025-08-29 UTC."],[[["\u003cp\u003eThe Admin SDK Groups Migration service enables administrators to migrate emails from public folders and distribution lists to Google Groups using Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eThis advanced service requires prior enabling in Google Workspace domains (including resellers) before use.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can leverage the Admin SDK Groups Migration API to programmatically manage email migration workflows.\u003c/p\u003e\n"],["\u003cp\u003eSample code provided demonstrates how to migrate RFC 822 formatted emails from Gmail to a designated Google Group.\u003c/p\u003e\n"],["\u003cp\u003eComprehensive documentation and support resources are available to guide developers in utilizing the service effectively.\u003c/p\u003e\n"]]],[],null,["# Admin SDK Groups Migration Service\n\nThe Admin SDK Groups Migration service allows you to use the Admin SDK's\n[Groups Migration API](/admin-sdk/groups-migration) in Apps Script. This\nAPI gives administrators of Google Workspace domains\n(including resellers) the\nability to migrate emails from public folders and distribution lists to\nGoogle Groups discussion archives.\n| **Note:** This is an advanced service that must be [enabled before use](/apps-script/guides/services/advanced).\n\nReference\n---------\n\nFor detailed information on this service, see the\n[reference documentation](/admin-sdk/groups-migration/v1/reference)\nfor the Admin SDK Groups Migration API. Like all advanced services in Apps\nScript, the Admin SDK Groups Migration service uses the same objects, methods,\nand parameters as the public API. For more information, see [How method signatures are determined](/apps-script/guides/services/advanced#how_method_signatures_are_determined).\n\nTo report issues and find other support, see the\n[Admin SDK Groups Migration support guide](/admin-sdk/groups-migration/support).\n\nSample code\n-----------\n\nThe sample code below uses [version 1](/admin-sdk/groups-migration/v1/reference)\nof the API.\n\n### Migrate emails from Gmail to a Google Group\n\nThis sample gets three RFC 822 formatted messages from the each of the latest\nthree threads in the user's Gmail inbox, creates a blob from the email content\n(including attachments), and inserts it in a Google Group in the domain. \nadvanced/adminSDK.gs \n[View on GitHub](https://github.com/googleworkspace/apps-script-samples/blob/main/advanced/adminSDK.gs) \n\n```javascript\n/**\n * Gets three RFC822 formatted messages from the each of the latest three\n * threads in the user's Gmail inbox, creates a blob from the email content\n * (including attachments), and inserts it in a Google Group in the domain.\n */\nfunction migrateMessages() {\n // TODO (developer) - Replace groupId value with yours\n const groupId = 'exampleGroup@example.com';\n const messagesToMigrate = getRecentMessagesContent();\n for (const messageContent of messagesToMigrate) {\n const contentBlob = Utilities.newBlob(messageContent, 'message/rfc822');\n AdminGroupsMigration.Archive.insert(groupId, contentBlob);\n }\n}\n\n/**\n * Gets a list of recent messages' content from the user's Gmail account.\n * By default, fetches 3 messages from the latest 3 threads.\n *\n * @return {Array} the messages' content.\n */\nfunction getRecentMessagesContent() {\n const NUM_THREADS = 3;\n const NUM_MESSAGES = 3;\n const threads = GmailApp.getInboxThreads(0, NUM_THREADS);\n const messages = GmailApp.getMessagesForThreads(threads);\n const messagesContent = [];\n for (let i = 0; i \u003c messages.length; i++) {\n for (let j = 0; j \u003c NUM_MESSAGES; j++) {\n const message = messages[i][j];\n if (message) {\n messagesContent.push(message.getRawContent());\n }\n }\n }\n return messagesContent;\n}\n```"]]