Skip to content

Gmail — Get email by ID

Type: gmail-get-email  ·  Package: Gmail v1.0.4  ·  Output: Dictionary<string,object>

Gets a full email by its ID: body (text and HTML), headers (sender, recipients, subject, date) and attachment info. Use it when Get emails gave you the list without bodies and you now need the content of a specific one.

It works on the session created with Gmail — Connect. Pass it in the session parameter, or place this activity inside the body of Gmail — Connect to inherit it automatically.

The id is the one in each item returned by Get emails (id key) or the one returned by Send, Reply and Forward. It only reads: it does not mark the email as read.

The body is built by walking the message parts: it takes the first plain-text part and the first HTML part. If the email only has HTML, body holds that HTML with the tags stripped, handy for text searches or for passing to AI Extract.

ParameterTypeDefaultDescription
idstring—Message ID (from Get emails).
ParameterTypeDefaultDescription
sessionZoanGmailSession—Gmail — Connect session (inherited inside body).

Returns a Dictionary<string,object> with the same keys as each item of Get emails with includeBody turned on:

KeyTypeContent
id, threadIdstringMessage ID and its conversation ID.
from, to, cc, subject, datestringHeaders as is (cc is null if none).
snippetstringExcerpt from the beginning of the message.
labelsList<string>IDs of the email’s labels.
unreadbooltrue if unread.
bodystringPlain text; if there is only HTML, the HTML with tags stripped; "" if there is no body.
bodyHtmlstringHTML body, or null.
attachmentsList<Dictionary>One item per attachment: filename, mimeType, size (bytes), attachmentId. Empty list if none.

The attachments list describes the attachments but does not download them; to save them use Download attachments.

MessageCause and fix
'id' is required.id is empty or the expression returned null.
Requested entity was not found.No email with that ID exists in the mailbox (deleted, or the ID belongs to another mailbox).
No Gmail session available. …You didn’t pass session and the activity is not inside Connect’s body.
Gmail — Connect credential = credential("gmail-support")
└─ body:
Gmail — Get emails query = "is:unread subject:order" → output: newEmails
For each item in newEmails
└─ Gmail — Get email by ID id = item["id"] → output: email
AI Extract prompt = str(email["body"]) schema = … → output: order
Gmail — Download attachments id = email["id"] folder = "C:\orders" → output: files