---
sourceDocument: Xanadu ServiceNow AI Platform Administration
sourceDocumentLink: https://www.servicenow.com/docs/r/xanadu/platform-administration

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Mail script variables

# Mail script variables {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

Certain variables are available when processing mail_script scripts.
For examples of mail scripts, see [Example scripting for email notifications](https://www.servicenow.com/docs/mheYxg9vbpnk0LSyCTrMug "Examples of scripting for email notifications.").  
{#r_MailScriptAPI__table_psj_g1q_rq__entry__2}

| 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. {#r_MailScriptAPI__ul_b5v_l1q_rq}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](https://www.servicenow.com/docs/access?context=c_GlideEmailOutboundScopedAPI&version=xanadu&pubname=xanadu-api-reference&ft:locale=en-US). |
[Table 1. Mail script variables]

{#r_MailScriptAPI__table_psj_g1q_rq}
**Related concepts**   

* [JavaScript in emails](https://www.servicenow.com/docs/B97pQX3mUZ4uPBVTjI3ouQ "Create mail scripts in System Notifications > Email > Notification Email Script , and refer to them by using ${mail_script:script name} in the script field.")  
**Related reference**   

* [Example scripting for email notifications](https://www.servicenow.com/docs/mheYxg9vbpnk0LSyCTrMug "Examples of scripting for email notifications.")
* [Useful attachment scripts](https://www.servicenow.com/docs/vU~ZKZWO6_Kfrfcg~rlxXQ "This is a searchable version of the Useful Attachment Scripts.")

