Method: users.messages.import
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
仅将邮件导入此用户的邮箱,并执行与通过 SMTP 接收邮件类似的标准电子邮件递送扫描和分类。此方法不会执行 SPF 检查,因此对某些垃圾邮件(例如尝试进行域名欺骗的邮件)可能不起作用。此方法不会发送消息。
HTTP 请求
- 上传 URI,用于媒体上传请求:
POST https://gmail.googleapis.com/upload/gmail/v1/users/{userId}/messages/import
- 元数据 URI,用于仅涉及元数据的请求:
POST https://gmail.googleapis.com/gmail/v1/users/{userId}/messages/import
网址采用 gRPC 转码语法。
路径参数
参数 |
userId |
string
用户的电子邮件地址。特殊值 me 可用于指示经过身份验证的用户。
|
查询参数
参数 |
internalDateSource |
enum (InternalDateSource )
Gmail 邮件内部日期的来源。
|
neverMarkSpam |
boolean
忽略 Gmail 垃圾邮件分类器的决定,并永远不要在收件箱中将此电子邮件标记为垃圾邮件。
|
processForCalendar |
boolean
处理电子邮件中的日历邀请,并将提取的所有会议添加到此用户的 Google 日历中。
|
deleted |
boolean
将电子邮件标记为已永久删除(而非“回收站”),并且仅在 Google 保险柜中向保险柜管理员显示。仅适用于 Google Workspace 账号。
|
请求正文
请求正文包含一个 Message
实例。
响应正文
如果成功,则响应正文包含一个 Message
实例。
授权范围
需要以下 OAuth 范围之一:
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.insert
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[],[],null,["# Method: users.messages.import\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nImports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. This method doesn't perform SPF checks, so it might not work for some spam messages, such as those attempting to perform domain spoofing. This method does not send a message.\n\n### HTTP request\n\n- Upload URI, for media upload requests: \n `POST https://gmail.googleapis.com/upload/gmail/v1/users/{userId}/messages/import`\n- Metadata URI, for metadata-only requests: \n `POST https://gmail.googleapis.com/gmail/v1/users/{userId}/messages/import`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------------------------------------------|\n| `userId` | `string` The user's email address. The special value `me` can be used to indicate the authenticated user. |\n\n### Query parameters\n\n| Parameters ||\n|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `internalDateSource` | `enum (`[InternalDateSource](/workspace/gmail/api/reference/rest/v1/InternalDateSource)`)` Source for Gmail's internal date of the message. |\n| `neverMarkSpam` | `boolean` Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox. |\n| `processForCalendar` | `boolean` Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user. |\n| `deleted` | `boolean` Mark the email as permanently deleted (not TRASH) and only visible in [Google Vault](http://support.google.com/vault/) to a Vault administrator. Only used for Google Workspace accounts. |\n\n### Request body\n\nThe request body contains an instance of [Message](/workspace/gmail/api/reference/rest/v1/users.messages#Message).\n\n### Response body\n\nIf successful, the response body contains an instance of [Message](/workspace/gmail/api/reference/rest/v1/users.messages#Message).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://mail.google.com/`\n- `\n https://www.googleapis.com/auth/gmail.modify`\n- `\n https://www.googleapis.com/auth/gmail.insert`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]