HTML Renders Unexpectedly When Viewed from Email "Preview HTML Body" and "Notification Preview"



HTML renders unexpectedly when viewed from the platform email tools "Preview HTML Body” and "Notification Preview”. For example these views may have unexpected fonts.

Note that the HTML looks "normal" when an email is viewed from an email client and also in a record's Activity trail.


Applies to any release.


The ServiceNow platform is sanitizing the HTML when using the "Preview HTML Body” and "Notification Preview” email functions.


This will happen if the HTML is invalid (although browsers and email clients may allow the invalid HTML). We allow customers full control over HTML, so there is no sanitation when the emails are sent out or displayed in the Activity trail of records.

The sanitation process is fixing the invalid HTML and making it look bad when rendered.

To see the difference between sanitized and un-sanitized HTML, you can run a script to output the sanitized version of an email record from Scripts - Background:

var gr1 = new GlideRecord('sys_email');
gr1.get('<email sys_id>');

The output can be saved to a .html file and viewed in a browser.

This includes any customer created HTML in email notifications, email templates, or email scripts.

For example this is an email script that uses the deprecated font tag:

(function runMailScript(current, template, email, email_action, event) {

template.print("<font size='2' face='tahoma,arial,helvetica,sans-serif'>");

})(current, template, email, email_action, event);


The font tag is deprecated and should not be used. CSS should be used to style the font instead.

This is just one example of invalid HTML, it is the responsibility of the creators of the HTML to be sure that the HTML is valid and conforming to HTML specifications.