- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 03:59 AM
I want to delete emails from the email log from outbox. Not all the mails, only from outbox i want to delete. Can anyone help me out with the background script to delete the emails from the log.
Thank you very much in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 04:14 AM
You can check this out.
var gr = new GlideRecord('sys_email');
gr.addEncodedQuery('mailbox=outbox');
gr.query();
gr.next();
gr.deleteMultiple();
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 04:13 AM
Hi Bharat,
You can try this out
var gr = new GlideRecord('sys_email');
gr.addEncodedQuery('mailbox=outbox');
gr.query();
gr.next();
gr.deleteMultiple();
There might be large number of logs in the outbox, Make sure you run it on a lower instance first.
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 04:15 AM
Thank you so much...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 04:46 AM
Hello Bharat,
If I have answered your query, can you please mark my response as correct answer so we close this thread?
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 04:24 AM
Hi Bharat,
I tried in our Dev instance and it is working, Can you try the below script.
disableEmails();
function disableEmails() {
var users = new GlideRecord("sys_email");
users.addQuery('sys_created_on', '2013-08-15 23:35:28');
users.query();
users.deleteRecord();
while (users.next()) {
users.deleteRecord();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2020 08:43 AM
Only this worked for me where "sys_email" is the outbox table:
var gr = new GlideRecord("sys_email");
gr.query();
gr.deleteMultiple();