Is there a way to identify the attachments in Email notification?

msowmiya
Tera Contributor

Sys_email table contains the list of emails sent or received in an instance. Do we have any method to find the number of records which have attachments in it. 

7 REPLIES 7

Jaspal Singh
Mega Patron
Mega Patron

Hi Sowmiya,

 

There would be a related list in the mail log named 'Email Attachments' if corresponding mail has any attachment. Alternatively, you can look for sys_email_attachment table [Email Attachments] for additional details.

 

Thanks,

Jaspal Singh

 

Hit Helpful or Correct on the impact of response.

Nootan
ServiceNow Employee
ServiceNow Employee

Hi 

You can use this

var ga = new GlideAggregate("sys_email_attachment");
ga.setGroup(true);
ga.groupBy("email");
ga.query();

gs.log(ga.getRowCount()); //Number of Emails having attachments

Or You can navigate to table sys_email_attachment and do a group by operation on email. Then you can see the row count.

Thanks

msowmiya
Tera Contributor

Hi Nootan, Jaspal,

 

Thanks for the reply.. 

We are on Madrid release and this table, sys_email_Attachment is available from Newyork version. 

Another other possible ways?

 

Thanks,

Sowmiya M 

Hi Sowmiya,

Try below code

 

var gr=new GlideRecord('sys_attachment');

gr.addQuery('table_name','sys_email');

gr.query();

 

gs.addInfoMessage(gr.getRowCount());  // gives number of email records having attachments

 

Mark helpful if this is useful.

Thanks.