Has anyone managed to get HTML formatting to work on Calendar Invites?

awright
Kilo Expert

When we make Meeting Invitation type emails, we would like to be able to put HTML formatting into the text that comes through in the description, but servicenow always sets the message type to "text/calendar", meaning that HTML formatting for the description goes out the window. (I have tried using altrep on our calendar template but to no avail.

 

I was thinking maybe that we should try and send these as multipart/mixed email notifications and set the content type in HTML before each part, but I am not certain it is the best way of going about it.

 

Has anyone managed to get HTML formatting to work on Calendar Invites?

1 ACCEPTED SOLUTION

awright
Kilo Expert

Hi, sorry if this is a little late.



What we ended up doing was adding in "X-ALT-DESC;FMTTYPE=text/html:" as an alternative description (ALTREP didn't seem to do anything useful), then formatted the HTML string to all fit on to a single line.



An additional thing to watch for is to make sure that the original plain text Description has no HTML tags in it for users that use plaintext only (though all plaintext things like ipads seem to do is interpret the HTML version anyway).


View solution in original post

12 REPLIES 12

Hi,

I would like to know where in Service Now instance do I need to update "X-ALT-DESC;FMTTYPE=text/html"?

I want calendar invite in html format.

Thanks in advance.

So after a hundred attempts at sending HTML via a field to the X-ALT-DESC;FMTTYPE=text/html: tag, the ICAL sanitizer removed all tags and converted them into code, so < became &lt and > became &gt, and no matter what i tried i couldnt get around that. so when faced with a challange i rose.  I instead created a unique value to go along with the tag like X-ALT-DESC;FMTTYPE=text/html:<<REPLACE_ME_NOW>>   and i created an after business rule on the sys_email table, that stored the body_text field into a variable, then did a replace of X-ALT-DESC;FMTTYPE=text/html:<<REPLACE_ME_NOW>> with -ALT-DESC;FMTTYPE=text/html:gr.field_name after running a gr.addQuery(current.table_name); gr.get(current.instance);  for my instance we are using this for emergency change freezes, to send an ical with a formatted body for outlook...  the code is as follows:

Table:sys_email
When:after

On: Insert
Condition: target table = cmn_schedule_span 

(id add another condition to ensure only the ical notifications you want are being sent out, for me i used subject)

    var calfreeze = new GlideRecord(current.target_table);
    calfreeze.get(current.instance);
    var html = calfreeze.u_emergency_freeze_body_html;
    var prefix = 'X-ALT-DESC;FMTTYPE=text/html:';
    var replace = 'X-ALT-DESC;FMTTYPE=text/html:<<insert_here>>';
    var bodytext = current.body_text;
    var newbody = bodytext.replace(replace, prefix + html);
    current.body_text = newbody;
    current.update();

 

guptashalini041
Kilo Contributor

Hi,

Where to use code "X-ALT-DESC;FMTTYPE=text/html" in servicenow. Can you please share the sample code snippet.

Thanks

ravigupta
Mega Contributor

Hi Experts,

Where to use code "X-ALT-DESC;FMTTYPE=text/html" in ServiceNow. Can you please share the sample code snippet.

Thanks

Ravi Gupta

Hi! This is a really helpful thread, and so is this article: ServiceNow Calendar Invites

I was able to get it work by using the X-ALT-DESC tag, as shown below:

  1. Make sure the email notification is of "Type": "Meeting Invitation"
  2. Also, make sure the contents of "Message HTML" field is blank
  3. On the email template record, add the following as a new line right after the "DISCRIPTION" tag under  "Message text" field:

    X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><html><head><title></title></head><body><SPAN LANG="en-us"><Font face="Times New Roman">I simply <b> want some bold </b> here 555</font></span></body></html>

 

Example:

BEGIN:VCALENDAR

PRODID:-//Service-now.com//Outlook 11.0 MIMEDIR//EN

VERSION:2.0

METHOD:REQUEST

BEGIN:VEVENT

ATTENDEE;ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:${to}

ORGANIZER:MAILTO:from email address

LOCATION:meeting location

DTSTART:${dtstart}

DTEND:${dtend}

UID:${sys_id}

DTSTAMP:${dtstamp}

DESCRIPTION:meeting body

X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><html><head><title></title></head><body><SPAN LANG="en-us"><Font face="Times New Roman">I simply <b> want some bold </b> here 555</font></span></body></html>

SUMMARY:subject line

X-MICROSOFT-CDO-BUSYSTATUS:BUSY

X-MICROSOFT-DISALLOW-COUNTER:TRUE

X-SNSYSID:${sys_id}

BEGIN:VALARM

TRIGGER:-PT15M

ACTION:DISPLAY

DESCRIPTION:Reminder

END:VALARM

END:VEVENT

END:VCALENDAR