Gmail API 總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Gmail API 是 RESTful API,可用於存取 Gmail 信箱和傳送郵件。對於大多數的網路應用程式而言,Gmail API 是授權存取使用者 Gmail 資料的最佳選擇,適用於各種應用程式,例如:
- 郵件擷取、建立索引和備份 (唯讀)
- 自動或透過程式傳送訊息
- 遷移電子郵件帳戶
- 整理電子郵件,包括篩選及排序郵件
- 在整個機構中統一電子郵件簽名
以下列出 Gmail API 中常用的詞彙:
- 訊息
- 電子郵件訊息,包含寄件者、收件者、主旨和內文。訊息建立後就無法變更。訊息是由訊息資源表示。
- 討論串
- 一系列相關訊息,構成一則對話。在電子郵件用戶端應用程式中,當一或多名收件者回覆郵件時,就會形成郵件串。
- 標籤
用來整理訊息和討論串的機制。舉例來說,使用者可以建立「稅務」標籤,並套用至所有與稅務相關的郵件和郵件串。標籤分為兩種:
- 系統標籤
- 內部建立的標籤,例如
INBOX
、TRASH
或 SPAM
。這些標籤無法刪除或修改。不過,部分系統標籤 (例如 INBOX
) 可以套用至郵件和郵件串,或從郵件和郵件串中移除。 - 使用者標籤
- 使用者建立的標籤。使用者或應用程式可以刪除或修改這些標籤。使用者標籤由標籤資源代表。
- 草稿
未傳送的訊息。您可以替換草稿中的訊息。
傳送草稿後,系統會自動刪除草稿,並建立具有 SENT
系統標籤的郵件。草稿以草稿資源表示。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["# Gmail API Overview\n\nThe Gmail API is a RESTful API that can be used to access Gmail mailboxes and\nsend mail. For most web applications the Gmail API is the best choice for\nauthorized access to a user's Gmail data and is suitable for various\napplications, such as:\n\n- Read-only mail extraction, indexing, and backup\n- Automated or programmatic message sending\n- Email account migration\n- Email organization including filtering and sorting of messages\n- Standardization of email signatures across an organization\n\nFollowing is a list of common terms used in the Gmail API:\n\n*Message*\n: An email message containing the sender, recipients, subject, and body. After a\n message has been created, a message cannot be changed. A message is represented\n by a [message resource](/workspace/gmail/api/reference/rest/v1/users.messages#Message).\n\n*Thread*\n: A collection of related messages forming a conversation. In an email client\n app, a thread is formed when one or more recipients respond to a message with\n their own message.\n\n*Label*\n\n: A mechanism for organizing messages and threads. For example,\n the label \"taxes\" might be created and applied to all messages and threads\n having to do with a user's taxes. There are two types of labels:\n\n *System labels*\n : Internally-created labels, such as `INBOX`, `TRASH`, or `SPAM`. These labels\n cannot be deleted or modified. However, some system labels, such as `INBOX`\n can be applied to, or removed from, messages and threads.\n\n *User labels*\n : Labels created by a user. These labels can be deleted or modified by the\n user or an application. A user label is represented by a\n [label resource](/workspace/gmail/api/reference/rest/v1/users.labels).\n\n*Draft*\n\n: An unsent message. A message contained within the draft can be replaced.\n Sending a draft automatically deletes the draft and creates a message with\n the `SENT` system label. A draft is represented by a\n [draft resource](/workspace/gmail/api/reference/rest/v1/users.drafts).\n\nNext steps\n----------\n\n- To learn about developing with Google Workspace APIs, including handling\n authentication and authorization, refer\n to [Get started as a Google Workspace developer](/workspace/guides/getstarted-overview).\n\n- To learn how to configure and run a simple Gmail API app, read the\n [Quickstarts overview](/workspace/gmail/api/guides/quickstarts-overview)."]]