How to Add "To" Address in email

Sanjeev Kumar1
Kilo Sage


Hi All,

I am using email methode   ' addAddress(String type, String address, String displayname) - type can be "cc" or "bcc"   '

in my email script with the help of this methode I am able to send "CC" OR "BCC" but

I want to set "TO" address dynamically with the help of e-mail script.

Please let me know it's posible in ServiceNow.

1 ACCEPTED SOLUTION

If this notification is being triggered by an event, it sounds like you will have to use another form of script to set a list of additional users of who you want to add to the "To:" list and pass them into the notification under Event Parm 1 and/or Event Parm 2.



Wiki URL Link:


Email Notifications - ServiceNow Wiki


Event parm 1 contains recipient (Visibile from the Advanced view) Select this check box (true) if the event parameter 1 contains the email recipient. This field is only visible when the Send when field has the value Event is fired.
Event parm 2 contains recipient (Visibile from the Advanced view) Select this check box (true) if the event parameter 2 contains the email recipient. This field is only visible when the Send when field has the value Event is fired.


Example:


gs.eventQueue("change.inserted", current, gs.getUserID(), gs.getUserName());



In the above example, the sys_id returned from "gs.getUserID()" is being passed as Parm1 and the "user_name" is passed as Parm2.



You could use the "eventQueue" function to pass another sys_id or email address.




Let me know if this helps and if this answers your question, please make sure to mark your question answered if so.  



Kind Regards,


Mike


View solution in original post

23 REPLIES 23

Hi Chennaiman,



Your answer is not correct I am not asking about "RepltTo". I am asking about   "To:".



So is there any way we set To: at run time.


just like "CC"



e. g.   addAddress('cc', 'example123@abc.com');


Hi Sanjeev,


Can you give more details as to what you are trying to solve?   Since you are able to supply the "To:" in a number of ways with email notifications, I'm not sure I entirely follow what you are trying to achieve by setting "To:" in a script at run time.



Perhaps with more detail, I may be able to help work out a solution.



Kind Regards,


Mike



Hi Mike,



When we create some Email Notification in service now we have a sction "who will receive" In this section we select some Users/Group or users Or Groups or both. and also select some template under section "What it will contain".



Now when system send e-mail to User or Group in email recipeant (To:) will contain User e-mail address.


e-mailTo.JPG



As shown in above Image.


We are able to set "Cc" with the help of "addAddress" function .


I want to set To: or recipent e-mail address with the help of email script.


I don't want to put any thing under "Who will receive" section.



If you have some solution let me know.



Thanks,


Sanjeev Kumar


NCR Corporation.