Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GmailMessage

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";

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

Hierarchy

  • GmailMessage

Index

Properties

bccRecipients

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

body: string

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

ccRecipients

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

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

subject: string

toRecipients

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

  • send(): boolean
  • Send the mail message via the Gmail API.

    Returns boolean

Static create

  • 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