Mail script variables

reference australia Updated Sep 10, 2026 1 min read r_MailScriptAPI.md
Raw file servicenow.com

Certain variables are available when processing mail_script scripts.

For examples of mail scripts, see Example scripting for email notifications.

Variable

Object Description

template

Handles printing from the mail script to the email message.

template.print("message"); //outputs message to the email body.

template.space("number of spaces"); //outputs spaces to the email body.

email_action

GlideRecord object for the email notification (sysevent_email_action).

event

GlideRecord object for the event that fired the notification (sysevent).

email

EmailOutbound object

Available methods:

  • addAddress(String type, String address, String displayname): type can be cc or bcc.
  • setFrom(String address): override the sender address.
  • setReplyTo(String address): override the reply to address.
  • setSubject(String subject): override the subject of the message.
  • setBody(String message): override the body of the message.

The email address that is passed by setFrom and setReplyTo needs to be in a valid form such as helpdesk@sn.com or Display Name <helpdesk@sn.com>. If the email address includes a 'Display Name', then that value overrides the instance's display name.

For more information, see GlideEmailOutbound - Scoped.

**Parent Topic:**[Scripting for email notifications](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/platform-administration/c_ScriptingForEmailNotifications.md)

Related topics

JavaScript in emails

Example scripting for email notifications

Useful attachment scripts

Search documentation
Search document titles and file paths on the australia branch