Styling Email Body inside mailto in a notification script

Sayantan Dutta1
Tera Contributor

Hi All,

 

We have received a requirement to redesign the Approve/Reject Mailto Notification Body So it will look like following sample:

 image001 (4).png

 

 

 

 

 

 

 

 

So, as part of development we have created a email script that runs the following code:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    // Add your code here
    var image = "/Approve.png";

    var response = "approve";

    var emailbod = "Please enter any approval comments here and press Send to submit your response. Comments are mandatory if you are rejecting the request.";

    // template.print(renderMailtoButton(img, response, emailbod));
    var instance = gs.getProperty("instance_name");
    var link = "https://" + instance + ".service-now.com";
    var mark = email.watermark;
    var number = current.number;
    var emailAddress = instance + "@service-now.com";
    if (current.getTableName().indexOf("sysapproval") != -1) {
        number = current.sysapproval.number;
    }
    template.print('<a href="mailto:' + emailAddress + '?subject=Re:' + number + ' ' + response + '&body=' + emailbod +"%0D%0A" + "%0D%0A" +  "Comments: " + "%0D%0A" + "%0D%0A" + mark + '"><img src="/Approve_en.png" alt="Approve" width="106"></a>');
})(current, template, email, email_action, event);

 

Therefore, the Inbound email body looking like this:

 

SayantanDutta1_1-1695631762284.png

 

So, we are missing the outer box for the Comment Field. 

Can anyone guide us how to include a create something like a single cell table for this comment field in the email script that can appear on the Email Body.

 

Thanks & Regards,

Sayantan

4 REPLIES 4

Omkar Kumbhar
Mega Sage
Mega Sage
You can try modifiying the below line to 
 
 
var myhtml = "<html><body><table><tr>";
myhtml = myhtml + "<tr><td><td valign='top'; width=17%><strong>" + Comments + ':' + "</strong></td><td><td width=83%>" + "</td></tr>";
 
template.print('<a href="mailto:' + emailAddress + '?subject=Re:' + number + ' ' + response + '&body=' + emailbod +"%0D%0A" + "%0D%0A" + myhtml " + "%0D%0A" + "%0D%0A" + mark + '"><img src="/Approve_en.png" alt="Approve" width="106"></a>');
If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

Sayantan Dutta1
Tera Contributor

Hi Omkar,

 

I tried implementing this but instead of creating the table, this whole string of myhtml including the html tags itself, are getting printed on the inbound email body.  

Were you able to do this?

Community Alums
Not applicable

I have the same requirement can you please guide me how you have done it.