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


---

# Scripting for email notifications

# Scripting for email notifications {#ariaid-title1}

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

Email scripts allow for business rule-like scripting within an outbound email
message.

With mail scripts, you can dynamically change the email output of your system based on
different criteria. Mail scripts allow you to perform simple tasks, such as displaying incident
data, and complex ones, such as making advanced database queries.

You can add a `${mail_script:script name}` embedded script tag to the body of
the email notification or template, replacing script name with the name of the
script you created. This makes it easy to use the same scripts in multiple email notifications or
templates.

If you manually enter a mail script bounded by `<mail_script>` and
`</mail_script>` in the body of a new or converted email notification or
template, and then attempt to save the record, a message asks whether the mail script should be
converted. In many cases, an unconverted mail script fails to run from inside the HTML editor. If
you select Yes, the script is added to the Email Script \[sys_script_email\]
table and is automatically replaced in the body with an embedded script tag
(`${mail_script:script_name}`).
* **[JavaScript in emails](https://www.servicenow.com/docs/B97pQX3mUZ4uPBVTjI3ouQ)**   
  Create mail scripts in System NotificationsEmailNotification Email Script, and refer to them by using `${mail_script:script name}` in the script field.
* **[Mail script variables](https://www.servicenow.com/docs/DVv1NBh8ZyTXXC2o1Bq~OQ)**   
  Certain variables are available when processing mail_script scripts.
* **[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.

*[\>]: and then


