- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 09:14 AM
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?
Thanks
Jamie
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 09:29 AM
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.
Vinod Kumar Kachineni
Community Rising Star 2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 09:17 AM
Have you tried below?
email.setReplyTo("joe.employee@yourcompany.com");
Muhammad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 09:47 AM
Hello Muhammad,
That would set the 'ReplyTo' field, rather than add the email address as a recipient to the 'TO' field.
thanks
Jamie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 09:29 AM
Hi Jamie,
Where are you triggering the email from?
If the user you want to add dynamically is on the field of the table you are triggering the email from you can use "Users/Groups in fields". You can use dot walking as well (accessing fields that are referenced on the table). So for example if an Incident triggers the email and I want to send the notification to the Manager of the caller:
For each record triggering the notification it will add the Manager of the Caller for that specific Incident to the "To" field.
Not sure if this is what you are looking for. If it is not, please share where the email address is coming from and why you want to add it via script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 09:46 AM
Hi Willem,
The scenario is that the notification is to inform service managers of a major outage. The notification contains a list of impacted sites (which are 'affected locations' against an incident). Each location has a service manager (which is held in a custom reference field to the user table). We only want the email to go to the service managers for the sites affected by this particular major outage. So in this case it does need to be scripted. I have it working using CC, but not using TO, and it seems there does have to be at least one user or email address set statically in the TO field. I think this will have to do!