MailScript - send BCC email not working

Felipe Morais
Tera Contributor

Hello guys,

I need to send an email notification via BCC. I tried using the following mail script to do so, but it's not working:
FelipeMorais_0-1702563913193.png


I used gs.log for debug, but i don't get any message in the System Logs, apparently it does not even call the script from the notification template.

This is my notification, where i call the mail script

FelipeMorais_1-1702564327934.png


The condition to send is when a record is inserted in the "HR case" table.

And for the "who will receive" i used my email as a test (and the email is sent to me, so the notification is working,), what's not working is the mail script.

Does anybody have an idea why the mail script is not working as supposed?

Thanks in advance!

FLM

17 REPLIES 17

Stefan Georgiev
Tera Guru

Hello @Felipe Morais ,

this is a pain, basically you can add bcc/cc from your mail script, but the notification is not going to get triggered if the tab Who will receive is empty, you need to provide at least one recipient from the Who will receive the notification to trigger the sending of the notification, the rest of the recipients you can add in your mail script.

If you have something like this:

StefanGeorgiev_0-1702565081777.png


the notification is not going to get send at all.

Hope that this helps you!

If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.

All the Best,
Stefan

At what point does it block the send? Would it be possible to put something in there and have it removed via a business rule on the sys_email table? Or would it never move from send-ready to sent at that point?

Hello @Michael George ,
it is not going to execution at all, ServiceNow is implemented that way, if it does not find a suitable user to send, from how will receive(active user, with email and active notifications), it just does not go to the mail script. You just can not send notification only to bcc/cc. I am not aware of a way yo remove the Recipient from Who will receive before the notification is sent.

A workaround is to send the notification to each member of the bcc/cc. You can do that with a for each in the flow or in the script. Not sure what is your case.

Hope that this helps you!

If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.

All the Best,
Stefan

Building further upon Stefan's response, a workaround that does NOT involve sending a notification to each member of the Bcc is as follows -

 

1. Specify someone on the Users reference of the Notification (sysevent_email_action). We chose 'System Administrator'.

2. Leave 'Event parm1 contains recipient' as empty. We are assuming parm1 is what you use in the Mail Script (sys_script_email) to build your Bcc list.

3. Have 'Send to event creator' checked if the notification is being triggered by the 'System Administrator'. Otherwise you can leave it unchecked.

4. Trigger an actual notification. This will create a record for 'System Administrator' and our notification in the Notification Messages (cmn_notif_message) table.

5. Go to that newly created record in cmn_notif_message and set the Filter to Unsubscribe. By default it will be empty. Now, 'System Administrator' will not get these emails whereas the blind-copied recipients will get them.

Yes, tested with my email and the notification is working. But the BCC mail script does not work. As i said, even the gs.log does not work, so i think the issue is with the mail script