Admin SDK Groups Migration Service Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The Admin SDK Groups Migration service in Apps Script allows administrators to migrate emails from public folders and distribution lists to Google Groups discussion archives.
This is an advanced service that requires enabling before use.
Detailed reference documentation for the Admin SDK Groups Migration API is available.
Sample code is provided to demonstrate migrating emails from Gmail to a Google Group.
The Admin SDK Groups Migration service allows you to use the Admin SDK'sGroups Migration API in Apps Script. ThisAPI gives administrators of Google Workspace domains(including resellers) theability to migrate emails from public folders and distribution lists toGoogle Groups discussion archives.
Note: This is an advanced service that must beenabled before use.Reference
For detailed information on this service, see thereference documentationfor the Admin SDK Groups Migration API. Like all advanced services in AppsScript, the Admin SDK Groups Migration service uses the same objects, methods,and parameters as the public API. For more information, seeHow method signatures are determined.
To report issues and find other support, see theAdmin SDK Groups Migration support guide.
Sample code
The sample code below usesversion 1of the API.
Migrate emails from Gmail to a Google Group
This sample gets three RFC 822 formatted messages from the each of the latestthree 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.
/** * 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. */functionmigrateMessages(){// TODO (developer) - Replace groupId value with yoursconstgroupId="exampleGroup@example.com";constmessagesToMigrate=getRecentMessagesContent();for(constmessageContentofmessagesToMigrate){constcontentBlob=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. */functiongetRecentMessagesContent(){constNUM_THREADS=3;constNUM_MESSAGES=3;constthreads=GmailApp.getInboxThreads(0,NUM_THREADS);constmessages=GmailApp.getMessagesForThreads(threads);constmessagesContent=[];for(leti=0;i <messages.length;i++){for(letj=0;j <NUM_MESSAGES;j++){constmessage=messages[i][j];if(message){messagesContent.push(message.getRawContent());}}}returnmessagesContent;}
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.