The GmailMessage object can be used to create and send mail messages through Gmail accounts, similar to those created by a Gmail action step. Creating and sending these messages happens in the background, with no user interface, so messages must be complete with recipients before calling send(). Sending is done via the Gmail API. Gmail accounts are authenticated when used for the first time using OAuth - to use more than one account, call create with different identifier parameters.

Example

let message = GmailMessage.create();
message.toRecipients = ["joe@sample.com"];
message.subject = "My test message";
message.body = "Body text";

let success = message.send();
if (!success) {
console.log("Sending gmail failed");
context.fail();
}

Hierarchy

  • GmailMessage

Constructors

  • Create new instance.

    Parameters

    • Optional identifier: string

    Returns GmailMessage

Properties

bccRecipients: string[]

Array of email addresses to use as BCC: recipients. Each entry can be a valid email address, or a name and email in the format Name<email>.

body: string

Body text of the mail message. Can be plain text or HTML if the isBodyHTML property is set to true.

ccRecipients: string[]

Array of email addresses to use as CC: recipients. Each entry can be a valid email address, or a name and email in the format Name<email>.

isBodyHTML: boolean

whether to treat the body string and plain text or HTML. When set to true, the body property should be set to full valid HTML.

subject: string
toRecipients: string[]

Array of email addresses to use as To: recipients. Each entry can be a valid email address, or a name and email in the format Name<email>.

Methods

  • Send the mail message via the Gmail API.

    Returns boolean

  • create a new object.

    Parameters

    • Optional identifier: string

      notes which for Gmail account to use. This string is an arbitrary value, but we recommend using the email address you wish to associate with the script. Each unique identifier will be associated with its own Credential.

    Returns GmailMessage

Generated using TypeDoc