setReplyTo not working mail in script

jimpaige
Giga Contributor

Hi all,

I've created a notification that's triggered on insert of a record to sc_req_item and I've used a Notificaion Email Script to add recipients using the email.setReplyTo function but the notification is not triggering.   The notification record itself is OK I think because if I add recipients in the 'Who will receive' tab the notification is triggered.   But, I can't use that because I need to get the recipients from variables in a catalog item.

Here's the mail script:

email.setReplyTo('john@example.com');

email.setReplyTo('roger@example.com');

email.setReplyTo('johnston@example.com');

email.setReplyTo(current.variables.requestor_email);

email.setReplyTo(current.variables.authorised_by_email);

The script is not working.   Any ideas anyone?

12 REPLIES 12

jimpaige
Giga Contributor

Hi Sanoop,



Thanks for the suggestion but alas it isn't working


jmcagod
Kilo Guru

Hi,



Did you get this to work?



In my case, I created an event and add it on the email.read Inbound Email. (When users tries to create a ticket, it should send a bounce back email)


The event works, but using it in the notification does not work.



This is how my event looks like gs.eventQueue("create_ticket", current, email.origemail, "").


**Parm1 contains the email of the sender


**Parm2 is empty (I just need the email of the sender/requestor)



since "Event Parm1 contains recipient" doesnt work, I created a mail script,



on my mail script:



var requestor = event.parm1;


gs.log("Update Bounce Back reply email: " + requestor);


email.setReplyTo(requestor);


var email_body = "Hi, please be advise to use the Portal to send ticket.. ";


template.print(email_body);




Thanks,


tillu
Giga Expert

Hi all, apologies for the late message. I had this issue and found a solution to this.



So, the reason for the setReplyTo not working in this case is due to timing. So, an email is sent and in the body you have inserted a script which changes the rely to. Problem is that the script will function when the email is inbound. When you set that reply to it will not influence the actions thereafter. Thus the default reply to in the mail settings will suffice.



What I did is create a mail script, with a template.print which prints an anchor tag, and the anchor tag would contain the mailto with the reply to setting there. Example:



template.print("<a href='mailto:emailaddress>?subject=Re:" + current.number + "%20-%20ANY SUBJECT TEXT HERE'> anchor text to display in notification</a>");



Insert the mail script call in the notification/template with ${mail_script: NAME OF THE MAIL SCRIPT CONTAINING THE ABOVE}