Skip to content

Gmail — Forward

Type: gmail-forward  ·  Package: Gmail v1.0.4  ·  Output: string

Forwards an existing email to other people, like Gmail’s Forward button: it includes the original message with its details (sender, date, subject, recipients) and, by default, its attachments. You can add a comment on top and attach extra files.

It is the way to route an email to the right team: an invoice to accounting, a complaint to customer service, a request to the person who approves it.

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.

  1. Fetches the email given in id (from Get emails) in full, with its attachments.
  2. Builds the forward: your comment (body), then a ---------- Forwarded message --------- block with the original’s details (From, Date, Subject, To) and its content. The subject gets the Fwd: prefix (not repeated if already there).
  3. If the original has HTML or you turn on isHtml, the forward is HTML; otherwise plain text. When it is HTML with isHtml = false, your comment is treated as text: it is escaped and its line breaks are kept.
  4. Adds the original attachments (unless you turn off includeAttachments) and those in attachments.
  5. Sends it from the session’s account, in the same thread as the original email, and returns the sent message’s ID.
ParameterTypeDefaultDescription
idstring—ID of the email to forward.
tostring | List—Recipient(s): text with addresses separated by commas or semicolons, or a list of addresses.
ParameterTypeDefaultDescription
sessionZoanGmailSession—Gmail — Connect session (inherited inside body).
ccstring | List—Cc recipient(s): text separated by commas or semicolons, or a list.
bccstring | List—Bcc recipient(s): text separated by commas or semicolons, or a list.
bodystring""Comment placed above the forwarded message.
isHtmlboolfalseIf true, the comment is interpreted as HTML.
includeAttachmentsbooltrueIf true, forwards the original attachments.
attachmentsstring | List—Path of one file, or a list of paths, to attach in addition to the original ones.

Returns a string with the forwarded message’s ID. Assign it to a variable if you need it later; otherwise you can ignore it.

MessageCause and fix
'id' is required.id is empty or the expression returned null.
'to' is required.No recipient was given, or the list is empty.
Attachment file not found.A path in attachments does not exist on the machine where the robot runs.
Requested entity was not found.No email with that ID exists in the mailbox.

Route emails with invoices to accounting and archive them:

Gmail — Connect credential = credential("gmail-frontdesk")
└─ body:
Gmail — Get emails query = "in:inbox subject:invoice has:attachment" → output: invoices
For each email in invoices
└─ Gmail — Forward id = email["id"] to = "accounting@example.com"
body = "Invoice received for recording."
Gmail — Archive id = email["id"]

Forward without the original attachments, but with a file of your own:

Gmail — Forward id = email["id"] to = "management@example.com" cc = "audit@example.com"
includeAttachments = false attachments = summaryPath