I want to delete emails from the email log which I created yesterday. Can anyone help me out with the background script to delete the emails from the log. They are are in ready to sent sate, but not sent.

hash3
Kilo Contributor

I   was working on something which created 15000 emails yesterday. They are sitting in the email log in ready to sent state. I turned off the email notifications to stop sending them. I need a background script to delete all the mails that were created yesterday. Its kind of urgent!!

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage
  • Do a gliderecord query on sys_email table and filter the records on the table.
  • Copy query and use encoded query to pick only emails that are needed.
  • Update the state of the records   to 'ignored'.

View solution in original post

3 REPLIES 3

Kalaiarasan Pus
Giga Sage
  • Do a gliderecord query on sys_email table and filter the records on the table.
  • Copy query and use encoded query to pick only emails that are needed.
  • Update the state of the records   to 'ignored'.

Mike Allen
Mega Sage

Capture.PNG


or:



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();


}



or:



var mu = new GlideMultipleUpdate('sys_email');


mu.addEncodedQuery('sys_created_onONYesterday@javascript:gs.daysAgoStart(1)@javascript:gs.daysAgoEnd(1)^type=send-ready');


mu.setValue('type',   'send-ignored');


mu.execute();