The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Email: Clear Outbox Queue Before Checking "Email sending enabled"

Desmo
Mega Guru

Hi,

I need to turn-on / enable "Email sending enabled" (Email Properties > Email sending enabled) on a non-production instance, but don't want to send emails in the Outbox queue. There are over 1000 emails in Ready state.

What is the most efficient method skipping or ignoring emails in the outbox? Business rule, perhaps. If you can provide a script, I'd greatly appreciate it.

Thanks,

Charlie

10 REPLIES 10

sachin_namjoshi
Kilo Patron
Kilo Patron

You can create test mailbox and configure this mailbox as outgoing mailbox so that all outgoing mails are sent to this mailbox on non production instance.



Regards,


Sachin


mike_zelnik
ServiceNow Employee
ServiceNow Employee

Hi Charlie,



If you want to quickly get all of the emails in your Outbox to your Skipped mailbox, you can run this script:



var rec = new GlideRecord('sys_email');


rec.addQuery('type','send-ready');


rec.query();


while (rec.next()) {


  rec.type = 'send-ignored';


  gs.print('Email ' + rec.subject + ' ignored');


  rec.update();


}



The Type field determines which mailbox emails are placed in and whether or not the SMTP Sender job picks them up.



It's also always a good idea to set the glide.email.test.user property on your sub-prod instances when enabling email sending.



Regards,
Mike


Hi Mike,

I've used your script it cleaned my outbox but all new emails also have the status ignored do you know why?

Is the script working in the background? How to fix it?

SanjivMeher
Kilo Patron
Kilo Patron

Set the test email address to your email id and enable the email. Then you can just delete all the emails you received from your servicenow instance in your outlook.


find_real_file.png



Please mark this response as correct or helpful if it assisted you with your question.