Run Mail Script in Email Template?

Cheri M
Kilo Sage

I have to be doing something wrong that someone will see here.

Here is my scenario: A user receives a notification from ServiceNow and has the option to click on a mailto link to send back and kick off an inbound action, similar to the approval emails. I want a the new email to popup with prefilled Subject/Body but I also need to include an email in the CC. I wrote a mail script to add the CC email address.   I am calling it in the email template but it just prints the variable and doesn't run.   I put in another variable and it seems to work fine.   I checked the source code and there isn't any funky HTML happening around it. Can we not call mail scripts in the email templates?   If not, what are my options?   Much appreciated!

2016-06-17 10_34_41-Re_ RTSK0010020 - Started  - Message (HTML).png

19 REPLIES 19

Chuck Tomasi
Tera Patron

Hi Cheri,



Per some information I got earlier this week, yes - mail scripts should run from within email templates.



What version of ServiceNow are you running.


We just went to Geneva Patch 7 this week.   geneva-08-25-2015__patch7-05-04-2016.


Thanks!


Erik Stolberg
Tera Guru

Confirming what Chuck said-- 2 email template examples in baseline code that run mail scripts: hr_case.resumed and hr_task.closed



Make sure you're using the correct parameters. From the wiki example:


email.addAddress("cc", "john.copy@example.com","John Roberts");


Steven Young
Tera Guru

1.   you will put a mailto   mail script in your email notification;


ex.   ${mailto:mailto.incident.resolve}



that in turn will pull the template as seen below.



in your email template you actually need to not put the script, but put field values like so



find_real_file.png



Then when you link is clicked in the email, it prepopulates the text in the "message" above in the body of the email.



I'm not sure if you can put a mail script within the message text to populate a cc address.



I can CONFIRM that mail scripts do run from within a template,   but i'm not sure they run within outlook to populate the cc.   I know the mail scripts run from template, because we use many mail scripts from within templates.
find_real_file.png




incident.png



However,   when i click the Resolve Incident,   no scripts run from there in Outlook, as these are ServiceNow Scripts, not Outlook scripts.