notifications are going to external email in servicenow

harsha vv
Tera Contributor

I want to find out which notifications are going to external emails?

do we need to write script or what can we do can anybody please tell me

4 REPLIES 4

Robbie
Kilo Patron
Kilo Patron

Hi @harsha vv,

 

All emails sent (and received) are logged within with Email System Logs. Type 'Emails' into the Navigation menu and click on the link under 'System Logs'.

 

From here you can adapt the filter accordingly:

- Created is This week (Select the date range you want to check for - eg This week or Last month etc)

- Type is Sent

- Recipients does not contain (your internal email address naming convention which identifies 'external' or non-internal emails such as @abc.com for example)

 

Screenshot 2024-09-27 at 10.19.17.png

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.



Thanks, Robbie

harsha vv
Tera Contributor

Hi @Robbie,

thanks for the reply, In my instance for one email id I have 30 to 40 notifications  I want to group them, but I am unable to do recipients group by. Can you check on this

 

hi @harsha vv 

you can try bellow script in background script;

var emailAG = new GlideAggregate('sys_email'); // Using GlideAggregate for the Email table
emailAG.addQuery('type', 'sent'); // Filter for sent emails
emailAG.addAggregate('COUNT'); // Specify that you want to count the records
emailAG.groupBy('recipient'); // Group by the recipient (optional)

emailAG.query(); // Execute the query

if (emailAG.next()) {
    var count = emailAG.getAggregate('COUNT'); // Get the count of sent emails
    gs.info('Total notifications sent to  emailId  : '+emailAG.recipient+' ' + count);
} else {
    gs.info('No notifications found for ' + emailId);
}

Hi @Rajesh Chopade1,

 

Thanks for the reply, I also  want what notifications are going to external email id