Change font and font size in email script include

Thrishna Strach
Kilo Expert

Hi all,

We are using email client templates all with the format Font=Source Sans Pro, Font size = 12. However, when we use the reply/ reply all/ forward buttons in an Email received/ sent in the instance, the text generated by the called email script include - insert_original_email_message - is set to Font=Verdana, Font size = 8.

So if I click anywhere except on the text below, font is SSP size 12. The text itself is font V size 8.

find_real_file.png

I've googled, and tried a few variations with template.print and then the desired font and size, but none of my attempts have worked.

This is the OOB script below. Does anyone know how I need to change this so that the text generated by the email script include is also font SSP size 12? Any help would be much appreciated.

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// This mail script is intended to be used by the response client templates and will only work as expected
// if called from a template with a content type of HTML. current represents the original sys_email record.
var uname = current.user;

if (current.type != 'received') {
var u = new GlideRecord('sys_user');
uname = current.sys_created_by;
if (u.get('user_name', uname))
uname = u.name.toString() + '<' + u.email.toString() + '>';
}

var cdate = new Date();
cdate.setTime(current.sys_created_on.getGlideObject().getNumericValue());

var usePlainTextResponseContent = gs.getProperty('glide.email_client.use_plain_text_response', 'false');

if ((usePlainTextResponseContent == 'true' && !current.body_text.isNil()) || current.body.isNil()) {
template.print("On " + cdate.toLocaleString() + ", '" + uname + "' wrote:\n\n");
// Process plain text to dislay in HTML email client
template.print(sn_notification.EmailResponse.getOriginalEmailTextContent(current.getUniqueValue()));
} else {
template.print("<div>On " + cdate.toLocaleString() + ", '" + uname + "' wrote:<br />");
template.print("<blockquote>");
// Remove html, head, body and style tags
template.print(sn_notification.EmailResponse.getOriginalEmailHtml(current.getUniqueValue()));
template.print("</blockquote></div>");
}
})(current, template, email, email_action, event);

 

The information in the email client template is:
font-family: 'Source Sans Pro', verdana, sans-serif; font-size: 12pt;

 

Kind regards,

Thrishna

6 REPLIES 6

Maik Skoddow
Tera Patron
Tera Patron

Unfortunately the source code of sn_notification.EmailResponse.getOriginalEmailHtml is not publicly available.

Therefore try to wrap it with HTML-Code that overrides the styles, for example:

template.print("<div style='font-family:Source Sans Pro !important;font-size:12px !important'>");
template.print(sn_notification.EmailResponse.getOriginalEmailHtml(current.getUniqueValue()));
template.print("</div>");

Hi Trishna

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

If not, please tell me what is still missing.

Kind regards
Maik

Hello Maik,

Sorry for the late reply. I've had some time off from work.

The wrapping seemed to do the trick. The font and size were showing the right values (although I did have to bump it up to 16 px to get size 12 pt?).

However, as you can see in the picture below, it's still not really giving me the right font. The left 'TEMPLATE' is Source Sans Pro, the right one, that I typed in after opening the email window, is something else. But in the font picker both show as SSP. 

find_real_file.png

When I go to the mailbox where I receive our dev instance emails it contains several fonts and sizes.

 

find_real_file.png

Yellow underline = Calibri (default font of my outlook - in the ServiceNow Email Client it was showing this text as SSP)

Green underline = SSP

 

So wrapping it shows the right values on the surface, but in reality it doesn't seem to change much. Thanks for the suggestion though.

Without having a look in your instance it is hard to say what is going wrong.

I just found another interesting approach you could try: https://blog.tgxn.net/applying-global-css-to-notifications/