Method: users.messages.insert
直接將郵件插入 (類似 IMAP APPEND
) 的信箱中,略過大部分的掃描和分類作業。不會傳送訊息。
HTTP 要求
- 上傳 URI,適用於媒體上傳要求:
POST https://gmail.googleapis.com/upload/gmail/v1/users/{userId}/messages
- 中繼資料 URI,適用於僅限中繼資料的要求:
POST https://gmail.googleapis.com/gmail/v1/users/{userId}/messages
這個網址使用 gRPC 轉碼語法。
路徑參數
參數 |
userId |
string
使用者的電子郵件地址。特殊值 me 可用於表示已驗證使用者。
|
查詢參數
參數 |
internalDateSource |
enum (InternalDateSource )
Gmail 郵件內部日期的來源。
|
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 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-05 (世界標準時間)。
[null,null,["上次更新時間:2024-09-05 (世界標準時間)。"],[[["Directly inserts a message into the user's mailbox, similar to `IMAP APPEND`, bypassing most scanning and classification."],["Supports two types of requests: uploading media content (`POST /upload/...`) and sending metadata only (`POST /...`)."],["Requires providing the user's email address (`userId`) as a path parameter and offers optional query parameters to control internal date source and deletion behavior."],["The request and response bodies both utilize the `Message` resource for structuring email data."],["To authorize, you'll need one of the specified OAuth scopes related to Gmail access and modification."]]],["This content outlines the process for directly inserting a message into a user's Gmail mailbox. Key actions include using `POST` requests to either an upload URI (`/upload/gmail/v1/users/{userId}/messages`) or a metadata URI (`/gmail/v1/users/{userId}/messages`). The `userId` path parameter identifies the user, and query parameters like `internalDateSource` and `deleted` provide further message properties. A `Message` instance is sent in the request and returned in the response. Authentication requires specific OAuth scopes.\n"]]