Dynamic 'Reply To' address based on 'To' address

udaykulal
Giga Contributor

Details: We have a requirement that, in Inbound Email integration, based on actual 'To' address of the email, Reply to address needs to be changed. Please see the attached ppt for more information.

We are aware that, Reply to address can be hard-coded in EMail notifications and Email client using Email client template. Can this address be made dynamic.

Basically when customer sends the email to IT_Helpdesk@tatasteel.com, it will be auto-routed to 'tatasteel@service-now.com' by tatasteel email team. When the incident is created, the notification generated should have reply to address 'IT_Helpdesk@tatasteel.com'.

Similarly when customer sends the email to HP.Helpdesk@tatasteel.com, it will be auto-routed to 'tatasteel@service-now.com' by tatasteel email team. When the incident is created, the notification generated should have reply to address HP.Helpdesk@tatasteel.com'

Is this feasible ?

1 ACCEPTED SOLUTION

Steve McCarty
Mega Guru

Uday,



You can dynamically change the from and reply to addresses in a notification by running a mail script with the following two lines:



email.setFrom("HP.Helpdesk@tatasteel.com");


email.setReplyTo("HP.Helpdesk@tatasteel.com");



If you can still read the original email when sending notifications and get the information you need then you won't need any other fields.   You will just have to write the script to read that message.   If the original email is difficult to get to, you may consider adding a field to your incident records to hold the reply to address.   It doesn't have to be displayed anywhere, but if the Inbound action can right to the field when you create the incident you could create a mail script that simply does this:



if(!current.u_replyto.nil())


{


email.setFrom(current.u_replyto);


email.setReplyTo(current.u_replyto);


}



This way, if the inbound action didn't record the reply to address, or if the incident was created some other way the notification could still be set to use a default from and reply to address.



-Steve


View solution in original post

8 REPLIES 8

ghsrikanth
Tera Guru

Hi Uday,



The below explanation is applicable for 'To' field, 'CC' field, 'BCC' field, I hope it will be helpful for you to resolve your requirement -


Construct a JSON String before you invoke the event


Put the JSON String in the event.parm1


gs.eventQueue('eventname', current, parm1, parm2);


parm2 can be empty



In the mail script you have to write - if event.parm1 is a JSON string then you can access in the email script like below


var jp = new JSONParser();


event.info = jp.parse(event.parm1);



I have given an example of a way that we follow to pass multiple information in parameters and this can give much more idea for you -


While you are queueing the event, follow this - gs.eventQueue('event', current, parm1, parm2);


1. parm1 contains JSON structure of following format


{


addressedTo : "John",


sendToList: "xyz@abc.com"


sendCcList:''abc@123.com",


sendBccList: "123@abc.com"',


}



In the email action, check only Event parm 1 cotains recipients check box, uncheck Event parm 2 as recipients check box.


Go to the email scripts tables-


Write a new email script: notification_email_script     //you can put any name and its advisable to separate the words with underscore


var jp = new JSONParser();


event.info = jp.parse(event.parm1);



event.addressedTo = event.info.addressedTo;



for (var i=0;i < event.info.sendToList.length; i++)


  email.addAddress("to",event.info.sendToList[i]);



for (var i=0;i < event.info.sendCcList.length; i++)


  email.addAddress("cc",event.info.sendCcList[i]);



for (var i=0;i < event.info.sendBccList.length; i++)


  email.addAddress("bcc",event.info.sendBccList[i]);



Go back to the email action -


In the message HTML put the below line at the top-


${mail_script:notification_email_script}




Mark if it is helpful or correct, feedback is appreciated


Steve McCarty
Mega Guru

Uday,



You can dynamically change the from and reply to addresses in a notification by running a mail script with the following two lines:



email.setFrom("HP.Helpdesk@tatasteel.com");


email.setReplyTo("HP.Helpdesk@tatasteel.com");



If you can still read the original email when sending notifications and get the information you need then you won't need any other fields.   You will just have to write the script to read that message.   If the original email is difficult to get to, you may consider adding a field to your incident records to hold the reply to address.   It doesn't have to be displayed anywhere, but if the Inbound action can right to the field when you create the incident you could create a mail script that simply does this:



if(!current.u_replyto.nil())


{


email.setFrom(current.u_replyto);


email.setReplyTo(current.u_replyto);


}



This way, if the inbound action didn't record the reply to address, or if the incident was created some other way the notification could still be set to use a default from and reply to address.



-Steve


Thanks Stephan. Seems to be correct answer. I will implement it and mark your answer correct


Ramya95
Tera Contributor

Can you please provide the exact solution like how you have implemented this requirement .