- 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:07 AM
Id suggest that you write the script and if it doesnt work then post it here and we can help you improve it. good for your own learning as well.
Basically you want to query the sys_email_list table and apply the query 'mailbox=outbox' and whatever qualifies you delete it (deleteMultiple())
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-06-2017 04:11 AM
Hi Anurag,
Thank you for your reply. below script is to delete the yesterday record. If i want to delete outbox. can you please modify this script and help me in this.
var email = new GlideRecord('sys_email');
email.addEncodedQuery('sys_created_onONYesterday@javascript:gs.daysAgoStart(1)@javascript:gs.daysAgoEnd(1)');
email.query();
while(email.next()){
email.deleteRecord();
}
- 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:14 AM
var email = new GlideRecord('sys_email');
email.addEncodedQuery('sys_created_onONYesterday@javascript:gs.daysAgoStart(1)@javascript:gs.daysAgoEnd(1)^mailbox=outbox');
email.query();
while(email.next()){
email.deleteRecord();
}
Before running this you might just want to print it once just to be sure that the filters are right.
and then delete.