jsn / ServiceNow, simplified.
AustraliaREFERENCE GUIDE

Mail script variables

On this page

Mail script variables

Certain variables are available when processing mail_script scripts.

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

<table id=“table_psj_g1q_rq”><thead><tr><th>

Variable

</th><th>

Object Description

</th></tr></thead><tbody><tr><td>

template

</td><td>

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.

</td></tr><tr><td>

email_action

</td><td>

GlideRecord object for the email notification (sysevent_email_action).

</td></tr><tr><td>

event

</td><td>

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

</td></tr><tr><td>

email

</td><td>

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 [email protected] or Display Name <[email protected]>. If the email address includes a ‘Display Name’, then that value overrides the instance’s display name.

For more information, see GlideEmailOutbound - Scoped.

</td></tr></tbody> </table>Parent Topic:Scripting for email notifications

Related topics

{Include mail scripts in email notifications}[]

{Example scripting for email notifications}[]

{Useful attachment scripts}[]

Keep exploring.

Find another answer, or bring this documentation into your own tools.