Gmail API 概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Gmail API 是一种 RESTful API,可用于访问 Gmail 邮箱和发送邮件。对于大多数 Web 应用,Gmail API 是以授权方式访问用户 Gmail 数据的最佳选择,适用于各种应用,例如:
- 只读邮件提取、编入索引和备份
- 自动或程序化消息发送
- 电子邮件账号迁移
- 电子邮件整理,包括过滤和排序邮件
- 组织内电子邮件签名的标准化
以下是 Gmail API 中使用的常见术语列表:
- 短信
- 包含发件人、收件人、主题和正文的电子邮件。创建消息后,无法更改消息。消息由 message 资源表示。
- 线程
- 构成对话的相关消息的集合。在电子邮件客户端应用中,当一位或多位收件人回复邮件时,系统会创建相应邮件会话。
- 标签
用于整理消息和消息串的机制。例如,您可以创建“税务”标签,并将其应用于与用户税务相关的所有邮件和会话。标签分为以下两种类型:
- 系统标签
- 内部创建的标签,例如
INBOX
、TRASH
或 SPAM
。这些标签无法删除或修改。不过,某些系统标签(例如 INBOX
)可以应用于邮件和会话,也可以从邮件和会话中移除。
- 用户标签
- 用户创建的标签。用户或应用可以删除或修改这些标签。用户标签由标签资源表示。
- 草稿
未发送的消息。可以替换草稿中包含的消息。
发送草稿会自动删除该草稿,并创建带有 SENT
系统标签的邮件。草稿由草稿资源表示。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):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)."]]