Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to clear all the emails in queue

rahul16
Giga Guru

find_real_file.png

There are 939 emails in the queue how to delete all the records and make it 0 so that I can enable Email sending?

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Hi Rahul

execute the following script:

var grEmail = new GlideRecord('sys_email');

grEmail.addEncodedQuery('type=send-ready');
grEmail.query();

if (grEmail.hasNext()) {
  grEmail.setValue('type', 'send-ignored');
  grEmail.updateMultiple();
}

Kind regards
Maik

View solution in original post

3 REPLIES 3

dmathur09
Kilo Sage

Hi Rahul,

Before enabling the email sending you can go to emails module and update all the emails from sent-ready to sent or sent-ignored.

Once all records have been updated, you can enable the email sending.

Regards,

Deepankar Mathur

Maik Skoddow
Tera Patron
Tera Patron

Hi Rahul

execute the following script:

var grEmail = new GlideRecord('sys_email');

grEmail.addEncodedQuery('type=send-ready');
grEmail.query();

if (grEmail.hasNext()) {
  grEmail.setValue('type', 'send-ignored');
  grEmail.updateMultiple();
}

Kind regards
Maik

Is this a client script on the sys_email table?  I am not a developer but I need to remove all emails in my DEV instance so I can test a few things.