- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 02:30 PM
Hi,
I have tested some functionality on Dev and want to enable outgoing emails but there are pilled up emails which should not be sent out.
What is your suggestion? Delete them or change their status to something so they can be ignored? What script background should be used?
Can I use below script to prevent sending the emails existing already in the system?
var rec = new GlideRecord('sys_email');
rec.addQuery('type','send-ready');
rec.query();
while (rec.next()) {
rec.type = 'send-ignored';
rec.update();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 07:37 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 02:32 PM
You can configure table in auto clean up job.
https://docs.servicenow.com/bundle/london-application-development/page/administer/auto-test-framework/concept/table-cleanup.html
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 02:38 PM
Is it anyway related to the context of my question?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 02:44 PM
You modified your original question.
Of course, answer will depend on your question.
Anyway, for your current question, you should mark pending emails as processed so that email engine doesn't pick up them again.
var rec = new GlideRecord('sys_email');
rec.addQuery('type','send-ready');
rec.query();
while (rec.next()) {
rec.state= 'processed';
rec.update();
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 06:54 PM
Do you think, system will send email even if the state is send ignored? Why my script cannot work here?