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

Hey Mike,


       


Thanks for your reply.



The thing is, I start a new discussion here(Email notification are not sending when an event is trigger ) and found that I have a problem in my dev instance. My logic and code is correct so I already contact to ServiceNow and they reset my instance. Now its working fine.



Thanks-


Macarius Anna


Hi Mike,



I have the same requirement of sending the email to few users at run time. By your thought i understand it is possible through events. But is there any way to do the same in mail script to set "To" Notification email addresses??



Thanks In advance


johnram
ServiceNow Employee
ServiceNow Employee

The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: Create an Email Notification




Visit http://docs.servicenow.com for the latest product documentation


Hi,


I understand this solution if it is triggered by an event, but what if the notification is triggered by a simple condition (as it is my case)?


There is not an e-mail script that allows me to set dinamically the "To" recipients?


Thanks in advance


thibault_richar
Kilo Explorer

Hello,



Thanks for your answer. Do you know if it's possible with the Dublin release ? I've tried to find the "Event parm" under the Advanced view without success. I'm wondering if I'm doing wrong or if it's available only in Dublin/Eureka but not on Calgary




Regards


Thibault