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

This is possible in the Calgary release as well as Dublin.



You may not see these fields depending on the setup of your notification.   These are usually only available when a notifications "Send when" is "Event is fired".



https://wiki.servicenow.com/index.php?title=Email_Notifications#Advanced_View_Fields


Indeed ! Thanks for your help !


matthew_magee1
Giga Guru

Hi Sanjeev,


Even though your question is answered, I'm still having a hard time understanding how to use event.parm1 to add to a 'To:' message.



What I'm having a hard time understanding is where to put the line


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



Is it in a business rule? Is it in an email script?



Can you outline how how got event.parm1 working?



Thanks!


Hi Matthew,


That code would be used in a business rule or anywhere else where it would be ran on the server (i.e. Business rule, Scheduled job/script).



Hope this helps.


Community Alums
Not applicable

Did you have your problem solved? If not, you can modify the Cc, Bcc, or To address lines in the email script. Take a look in the following link:
https://community.servicenow.com/community?id=community_question&sys_id=61fb4325db9cdbc01dcaf3231f96...