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

Thanks Deepak.   I do have a mail script that is setting the mailto: properties, which does work well.   How are you getting the reply to as the instance email address or are you not doing that?   I got distracted with some other tasks and ended up not finishing the script to call out the instance.   I'll try to write that on Monday.


Thank you for taking the time to reply!


Hi Cheri,



email.setReplyTo("ReplyTo@domain.com"); // will set the reply to email address for mail getting generated via servicenow, the moment user click on reply in outlook


email.setFrom("emailFrom@domain.com"); // will set the from email address for mail from servicenow, this actually changes the from address on email header


template.print("<a HREF=mailto:linkReplyTo@xyz.com?subject=Re:" +current.sysapproval.getDisplayValue() +"-approve>Click here to approve the request custom </a>");


template.print("<a HREF=mailto:linkReplyTo@xyz.com?subject=Re:" +current.sysapproval.getDisplayValue() +"-reject>Click here to reject the request custom </a>"); // this will auto populate reply to email address as "linkReplyTo@xyz.com" for email link embeded in email, just like "approve or reject" links


Unless I am misunderstanding you, that doesn't create the correct email address on the email you are sending back to ServiceNow.   I don't want to hard code support@domain.com because if I have testers go in Test and it will send it to Prod instead of Test, etc.   Your first two lines just create the replyTo on the original notification, which already has the correct email address.   Thank you for your input!


Cheri M
Kilo Sage

I just stumbled on my own question here.   My solution was when the inbound action was received it triggers an event that sends a notification to the CC groups.   It's working great for us.   I suppose it's a couple extra pieces but it wasn't worth the time to make this work all in one piece without hard coding something that would also have to be maintained between instances.


jatinder1
Tera Expert

I am facing the same issue. Any fix for this? I am in Madrid and using gmail for replies.