The CreatorCon Call for Content is officially open! Get started here.

Notification Email Script: Adding an email address to the 'TO' field

Jamsta1912
Tera Guru

Hello all,

I want to add some email addresses to the 'TO' field of an email notification, dynamically using an email notification script. There's a recent post asking the same thing here: https://community.servicenow.com/community?id=community_question&sys_id=947dff3fdb5adc549e691ea66896...

The suggested solution there was to do something like this:

email.addAddress("to","john.copy@example.com","John Roberts");

However that's not working for me, and according to the documentation below, this method can only be used to add recipients to the 'CC' or 'BCC' field. Is there a way to do this for the 'TO' field?

https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/script/server-scripting/referenc...

Thanks

Jamie

1 ACCEPTED SOLUTION

vkachineni
Kilo Sage

You cannot do "to"

Only allowed are "cc" and "bcc"

email.addAddress("cc","john.copy@example.com","John Roberts");

If your notification is a event based one, use the event parm1 / 2 "to" send the notification.
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

View solution in original post

7 REPLIES 7

vkachineni
Kilo Sage

You cannot do "to"

Only allowed are "cc" and "bcc"

email.addAddress("cc","john.copy@example.com","John Roberts");

If your notification is a event based one, use the event parm1 / 2 "to" send the notification.
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022

Ah yes I see. This could be the way forward. The notification is event driven, actually from a UI Action. So I could set event.parm1 to be the list of recipients and pass that in. It just means the processing gets done as part of the script in the UI Action, rather than in the mail script. Thank you. I will let you know if this works...

Hi Vkachineni,

Yes that has worked fine. Thank you 🙂