how to include mailto into a notification script

max_danielewicz
Giga Expert

Hi All,

i hope u r all ok.

Here is the situation

some times where approval via email is required, i use an email template and i call it in the message HTML area of the notification as follows: ${mailto:mailto.approved}. When the approver clicks on the link a new email is created which includes the REF number. Finally, an inbound action reads the received email and identifies the ticket by the ref code.

Problem

i would like to call the mailto.approved template from an email script and i have no idea how to.

would you know how to do this?

Optionally, in the email script i use the following code:

template.print('<a href="mailto:' + inst + '@service-now.com?SUBJECT=' + 'List of Close Contacts Informed' + '&amp;body=sys:'+ current.sys_id + '">Click here after contacting ALL close contacts</a>');

unfortunately, when i click on the link the new email does not includes the REF code. However, i added to the body of the email the sys_id of the record but the inbound action won't work.

var sysid = UserSsysid(email.body.sys);
var gr = new GlideRecord('u_covid_report');
gr.addQuery('sys_id', sysid);
gr.query();
if(gr.next()) {
gr.u_list_informed = true;
gr.comments = "reply from: " + email.from + "\n\n" + "updated via email by " + gr.u_manager;
gr.update();
}

would you know why this code wont work neither?

 

regards,

max

 

1 ACCEPTED SOLUTION

max_danielewicz
Giga Expert

Hi All,

thanks for your responses. Unfortunately, they did not work for me.

In order to solve the issue, i had to change the strategy a bit as per the following.

In the email script

I searched in the sys_watermark for the highest ref number for the specific ticket number and added it to the href. Also, made the subject to be a RE: (reply)

template.print('<a href="mailto:' + inst + '@service-now.com?SUBJECT=' + 'RE: List of Close Contacts Informed' + '&amp;body='+ wnum + '">Click here after contacting ALL close contacts</a>');

 

In the inbound action

changed to be a "reply" and use current values as i now have the watermark in the email.

 

Thanks to everyone for your time and help.

 

View solution in original post

6 REPLIES 6

Harsh Vardhan
Giga Patron

have you defined the mailto in template module. ?

 

instead of including via mail script you can define in your template. 

 

Please check my blog , i had created for some update using mailto and inbound action. 

https://community.servicenow.com/community?id=community_blog&sys_id=c248e709db191c106064eeb5ca9619a1

thank you very much for your quick response.

the mailto template's name is "mailto.signedoff"

the example you provided i had it done already and it is different to what i am trying to achieve. 

thanks

sample eg:

 

var ThisServer = gs.getProperty('instance_name') + '@service-now.com?subject=List of Close Contacts Informed';

 

var RefID = email.watermark;

 

 

Here make the changes based on your need. 

Sample example:

 

template.print('<p><p style="font-family: calibri; font-size: 14.5px"><a href="mailto:' + ThisServer + current.sysapproval.getDisplayValue() + ' - approve&body=' + RefID + '%20" target="_top"><b>I Approve</b></a></p>');

 

 

 

template.print('<p><p style="font-family: calibri; font-size: 14.5px"><b>If rejecting using the link below, </b>please remember to provide comments explaining the reason for the rejection in the body of the message.</b></p>');

 

 

 

template.print('<p><p style="font-family: calibri; font-size: 14.5px"><a href="mailto:' + ThisServer + current.sysapproval.getDisplayValue() + ' - reject&body=My reason for rejection follows >>> ' + RefID + '%20 target="_top"><b>I Reject</b></a></p>');

Jaspal Singh
Mega Patron
Mega Patron

Hi Max,

 

You can give link a check once.