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

 Release :

    - brazil

ft:locale :

    - en-US

ft:publication_title :

    - Brazil ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Scripting for email notifications

# Scripting for email notifications {#ariaid-title1}

Release version: Brazil  
Updated September 10, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read  
Email scripts enable you to use 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 enable you to perform simple tasks, such as displaying incident data, and complex ones, such as making advanced
database queries.

You can use the same scripts in multiple email notifications or templates by adding an `${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.

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}`).

When you manually enter a mail script enclosed in `<mail_script>` and `</mail_script>` tags in the body of a new or converted email notification or template and save the record, you
will be prompted to convert the mail script.

In many cases, mail scripts that are not converted fail to run within 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}`).

If you enter a mail script inside `${{mail_script:script name}}` and the HTML sanitizer configuration is done, the output of the mail script will be HTML sanitized. For more information about HTML sanitizer, see [HTML Sanitizer.](https://www.servicenow.com/docs/access?context=c_HTMLSanitizer&version=brazil&pubname=brazil-platform-security&ft:locale=en-US)
* **[JavaScript in emails](https://www.servicenow.com/docs/v2KGIW4s6YYWm9gUo9oTPg)**   
  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/mpLy~5AMNR~PPDoIxbG4Bw)**   
  Certain variables are available when processing mail_script scripts.
* **[Example scripting for email notifications](https://www.servicenow.com/docs/WJ1Nn5asRIu6p9OKn3SpUA)**   
  Examples of scripting for email notifications.
* **[Useful attachment scripts](https://www.servicenow.com/docs/SCwpYjjF8lC3L9UHutq2aA)**   
  This is a searchable version of the Useful Attachment Scripts.

*[\>]: and then


