For a list of methods for this resource, see the end of this page.
Resource representations
An email message.
{ "id": string, "threadId": string, "labelIds": [ string ], "snippet": string, "historyId": unsigned long, "internalDate": long, "payload": { "partId": string, "mimeType": string, "filename": string, "headers": [ { "name": string, "value": string } ], "body": users.messages.attachments Resource, "parts": [ (MessagePart) ] }, "sizeEstimate": integer, "raw": bytes }
Property name | Value | Description | Notes |
---|---|---|---|
historyId |
unsigned long |
The ID of the last history record that modified this message. | |
id |
string |
The immutable ID of the message. | |
internalDate |
long |
The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the Date header. However, for API-migrated mail, it can be configured by client to be based on the Date header. |
|
labelIds[] |
list |
List of IDs of labels applied to this message. | writable |
payload |
nested object |
The parsed email structure in the message parts. | |
payload.body |
nested object |
The message part body for this part, which may be empty for container MIME message parts. | |
payload.filename |
string |
The filename of the attachment. Only present if this message part represents an attachment. | |
payload.headers[] |
list |
List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as To , From , and Subject . |
|
payload.headers[].name |
string |
The name of the header before the : separator. For example, To . |
|
payload.headers[].value |
string |
The value of the header after the : separator. For example, someuser@example.com . |
|
payload.mimeType |
string |
The MIME type of the message part. | |
payload.partId |
string |
The immutable ID of the message part. | |
payload.parts[] |
list |
The child MIME message parts of this part. This only applies to container MIME message parts, for example multipart/* . For non- container MIME message part types, such as text/plain , this field is empty. For more information, see RFC 1521. |
|
raw |
bytes |
The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in messages.get and drafts.get responses when the format=RAW parameter is supplied. |
writable |
sizeEstimate |
integer |
Estimated size in bytes of the message. | |
snippet |
string |
A short part of the message text. | |
threadId |
string |
The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met:
|
writable |
Methods
- batchDelete
- Deletes many messages by message ID. Provides no guarantees that messages were not already deleted or even existed at all.
- batchModify
- Modifies the labels on the specified messages.
- delete
- Immediately and permanently deletes the specified message. This operation
cannot be undone. Prefer
messages.trash
instead. - get
- Gets the specified message.
- import
- Imports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. Does not send a message.
- insert
- Directly inserts a message into only this user's mailbox similar to
IMAP APPEND
, bypassing most scanning and classification. Does not send a message. - list
- Lists the messages in the user's mailbox.
- modify
- Modifies the labels on the specified message.
- send
- Sends the specified message to the recipients in the
To
,Cc
, andBcc
headers. - trash
- Moves the specified message to the trash.
- untrash
- Removes the specified message from the trash.