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

What I am using is a notification email script to collect the email.setReplyTo() users and then, I'm calling that script from the mailto.ITLeadershipDiscussion. Then I am using that template in the actual notification that is sent to the approvers by using mailto:mailto.ITLeadershipDiscussion which is the 3rd link that they see.



Ideally, what I would like the 3rd link when clicked to do is to populate the users in the TO section of the email from the email.setReplyTo() from the notification email script but not having any luck at all


Prasun
Giga Guru

Oh, Only one setReplyTo block will work, adding two setReplyTo is conflicting.


Abhinay Erra
Giga Sage

There have been many questions around this setting reply to from the script. But the setReplyTo() method never worked.


Hi Abhinay,



Well that's not good... are there any other alternatives? 😕



Thank you,


Yeny


Not that I know. But you can use event and business rule to do the scripting and set the email recipients. What is your use case here.