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
的執行例項。
授權範圍
需要下列其中一種 OAuth 範圍:
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.insert
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間: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)."]]