How to add a 'setReplyTo' (EmailOutbound method) in an email template?

YenGar
Mega Sage

Hi,

In the approval request email that an approver receives when an item is submitted contains the 'Click here to approve' and 'Click here to reject' links. When the approver clicks on any of those links, an email is opened up for that user to reply. What I am trying to do is to add a third link called 'Click here to start a discussion' and would like to populate the 'To' field in the email with specific email addresses to send to. I have tried using an email script in an email template but it is not working as expected.

Can someone please give me some ideas as to how I can resolve this issue? I'm stuck at this point and would really appreciate any ideas. Please see the below screen shots that show what I've done.

email script:

Name:it_leadership_discussion

script:

(function runMailScript(current, template, email, email_action, event) {

email.setReplyTo("yeny.doe@nrg.com");

email.setReplyTo("jane.doe@nrg.com");

})(current, template, email, email_action, event);

email template:

Name: mailto.ITLeadershipDiscussion

Subject: Re:${sysapproval} - ITLeadershipDiscussion

Message:

Click here to start a discussion ${sysapproval}

${mail_script:it_leadership_discussion}

This is a preview of the email that is sent out to the approvers:

ritm.PNG

Unfortunately, what I get in the email when I click on the link to reply to start a discussion is this:

reply email.PNG

I've also tried adding the 'setReplyTo' directly in the template and didn't work either.

Any ideas would be so much appreciated!!

10 REPLIES 10

Prasun
Giga Guru

Go to Email Notification Script and click on it_leadership_discussion Email Notification Script and write this block.



email.setReplyTo("joe.employee@yourcompany.com");




Hope this Helps.


Hi Prasun,



Thank you for your response!



I tried adding the email.setReplyTo in the email template that I am using the notification but it just added the string to the body of the email and not in the To field. Is this how it should be added or how?


email script.PNG



Also, this is what I have in the email notification that is using the email template.


email script.PNG



Thank you for your help!


Yeny


No, not in the template.


GO to Notification Email Script and select it_leadership_discussion script. In there add the script.


Remove additional setReplyTo


What I think, two blocks of setReplyTo is conflicting. better use



script:


(function runMailScript(current, template, email, email_action, event) {


email.setReplyTo("yeny.doe@nrg.com");


})(current, template, email, email_action, event);


Thank you Prasun,



Hmm, I tried that but still nothing. How would I be able to tie the mailto:mailto:ITLeadershipDiscussion to the notification email script though?



Yeny