迁移电子邮件
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在使用 Groups Migration API 将电子邮件迁移到 Google 群组之前,请先执行以下操作
正在关注
- 在迁移
将电子邮件发送到该群组的归档中。如需详细了解产品信息组和用户,请参阅
该
Directory API。
- 如果电子邮件发件人与目标群组具有相同的域名,请确认该电子邮件发件人是否存在
然后再将电子邮件迁移到目标群组的归档中
- 电子邮件内容的格式必须为
RFC 822 标准定义。
使用
Content-type: message/rfc822
标头。确认电子邮件消息的 To:
、From:
和 Date:
字段的格式正确无误。响应以 JSON 数据格式返回。
如需将电子邮件迁移到群组的归档,请发送 POST
HTTP 请求,添加 Authorization
标头,并将 GROUP_EMAIL_ADDRESS
替换为邮件的目标群组的电子邮件地址:
POST https://www.googleapis.com/upload/groups/v1/groups/GROUP_EMAIL_ADDRESS/archive?uploadType=media
示例请求
此示例会将电子邮件迁移到 samplegroup@googlegroups.com 归档库。Content-Length
的大小上限为 25 MB,其中包括邮件的元数据、正文和所有附件:
POST https://www.googleapis.com/upload/groups/v1/groups/samplegroup@googlegroups.com/archive?uploadType=media
Host: www.googleapis.com
Content-Type: message/rfc822
Content-Length: BYTES
Authorization: Bearer Auth token
METADATA_BODY
替换以下内容:
BYTES
:电子邮件中的字节数。
AUTH_TOKEN
:Authorization
标头。
METADATA_BODY
:电子邮件的元数据、正文和所有附件。
以下是采用 RFC 822 文本格式的电子邮件示例,已迁移到 samplegroup@googlegroups.com 的归档文件中。NNNN@mail.samplegroup.com
是此示例的邮件 ID。迁移的电子邮件的发件人是 samplesender@example.com,该电子邮件已迁移到 samplegroup@googlegroups.com 群组的归档文件夹:
Received: by 10.143.160.15 with HTTP; Mon, 16 Jul 2007 10:12:26 -0700 (PDT)
Message-ID: <NNNN@mail.samplegroup.com>
Date: Mon, 16 Jul 2007 10:12:26 -0700
From: samplesender@example.com
To: samplegroup@googlegroups.com
Subject: SUBJECT
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Delivered-To: samplegroup@samplegroup.com
This is the body of the migrated email message.
成功的响应会返回 200
HTTP 状态代码和迁移状态。
如需详细了解 responseCode
值,请参阅 Groups Migration API 参考文档。
{
"kind": "groupsMigration#groups",
"responseCode": "SUCCESS",
}
在 Google 群组界面上查看导入的帖子
在 Google 群组中,系统会为每位用户单独存储会话的已读/未读状态。时间
使用 Groups Migration API 插入邮件和会话,那么这些邮件会被视为与
它们是在 From:
标头中发送的。这意味着,除地址包含在 From:
标头中的用户外,所有其他用户都会看到这些邮件处于未读状态。例如:
在上一个 JSON 请求示例之后,标题为 SUBJECT
的消息会显示为已读
如果samplesender@example.com
登录了 Google 群组,但显示为未读
所有其他用户
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Migrate emails\n\nBefore migrating an email to Google Groups by using the Groups Migration API, do the\nfollowing\n\n- Confirm that the target group exists and the group's email is accurate before migrating an email message to that group's archive. For more information about listing groups and users, see the [Directory API](/workspace/admin/directory).\n- If the email's sender has the same domain as the target group, confirm the email sender exists before migrating the email message to the target group's archive.\n- The email message format must be in the [RFC 822 standard definition](https://www.w3.org/Protocols/rfc822/). Use the `Content-type: message/rfc822` header. Confirm that the email message's `To:`, `From:`, and `Date:` fields are properly formed. The response is returned in the [JSON](https://www.json.org/) data format.\n\nMigrate an email message to Google Groups\n-----------------------------------------\n\nTo migrate an email message to a group's archive, send a `POST` HTTP request,\ninclude the `Authorization` header, and replace\n\u003cvar translate=\"no\"\u003eGROUP_EMAIL_ADDRESS\u003c/var\u003e with the email address of the group that the messages\nare intended for: \n\n```\nPOST https://www.googleapis.com/upload/groups/v1/groups/GROUP_EMAIL_ADDRESS/archive?uploadType=media\n```\n\n### Example request\n\nThis example migrates email messages to the samplegroup@googlegroups.com archive. The\n`Content-Length` is limited to 25MB which includes the message's meta data, body, and any\nattachments: \n\n```\nPOST https://www.googleapis.com/upload/groups/v1/groups/samplegroup@googlegroups.com/archive?uploadType=media\nHost: www.googleapis.com\nContent-Type: message/rfc822\nContent-Length: BYTES\nAuthorization: Bearer Auth token\n\nMETADATA_BODY\n```\n\nReplace the following:\n- \u003cvar translate=\"no\"\u003eBYTES\u003c/var\u003e: the number of bytes in the email.\n- \u003cvar translate=\"no\"\u003eAUTH_TOKEN\u003c/var\u003e: the `Authorization` header.\n- \u003cvar translate=\"no\"\u003eMETADATA_BODY\u003c/var\u003e: the email's metadata, body, and any attachments.\n- The following is an example email message in RFC 822 text format that was migrated into the archive of samplegroup@googlegroups.com. The `NNNN@mail.samplegroup.com` is this example's Message-ID. The migrated email's sender is samplesender@example.com and the email is migrated to the archive of the samplegroup@googlegroups.com group: \n\n```\n Received: by 10.143.160.15 with HTTP; Mon, 16 Jul 2007 10:12:26 -0700 (PDT)\n Message-ID: \u003cNNNN@mail.samplegroup.com\u003e\n Date: Mon, 16 Jul 2007 10:12:26 -0700\n From: samplesender@example.com\n To: samplegroup@googlegroups.com\n Subject: SUBJECT\n MIME-Version: 1.0\n Content-Type: text/plain; charset=ISO-8859-1; format=flowed\n Content-Transfer-Encoding: 7bit\n Content-Disposition: inline\n Delivered-To: samplegroup@samplegroup.com\n\n This is the body of the migrated email message.\n```\n- A successful response returns a `200` HTTP status code and the migration status. For more information about `responseCode` values, see [the Groups Migration API reference](/workspace/admin/groups-migration/v1/reference/archive/insert). \n\n```text\n{\n \"kind\": \"groupsMigration#groups\",\n \"responseCode\": \"SUCCESS\",\n}\n```\n\nView imported messages on the Google Groups interface\n-----------------------------------------------------\n\n- On Google Groups, threads' read/unread state is stored separately for each user. When inserting messages and threads using the Groups Migration API, they're treated as if they were sent by the user in the `From:` header. This means that they appear as unread for all users, except for the user whose address is in the `From:` header. For example, after the previous JSON request example, the message titled `SUBJECT` appears as read if `samplesender@example.com` logged in to Google Groups, but appears as unread for all other users."]]