Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Delete emails from outbox

bharath3014
Kilo Contributor

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.

1 ACCEPTED SOLUTION

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


View solution in original post

14 REPLIES 14

Table is not sys_email_list, rather main table is "sys_email" only. So data should be deleted from table sys_email.

Venkateswarlu K
Mega Guru

HI Bharath


can u pls follow the below figure


Screenshot from 2017-04-06 16_41_16.png


i hope this will helpful to u


Hi Venkat,



Thank you for your reply. That i can do for 20, 30 records. But in outbox there are morethan 25000 records, i want to delete all the mails from outbox. can you please help me in that.


u can use this Bharath


using the back ground script



var gr = new GlideRecord('sys_email');


gr.addEncodedQuery('mailbox=outbox');


gr.setLimit('2500');


gr.query();


while(gr.next()){


gr.deleteMultiple();


gs.log('email deleted');


gr.update();


}


You wont need gr.update(); or the while loop if you are using deleteMultiple()


-Anurag