Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

Any suggestion on Script to move an email from outbox to sent?

Rain Vaine
Kilo Sage

Hello experts,
I am still not very confident on my scripting ability, does anyone of you have any advise on how to move na email from outbox to sent in mailboxes using a background script?
I tried to apply the following script:

var outboxEmails = new GlideRecord('sys_email');
outboxEmails.addQuery('mailbox', 'outbox');
outboxEmails.addQuery('type', 'send-failed');
outboxEmails.query();

//Go trhough the email in outbox with all the type 'sent'
while(outboxEmails.next()) {
        outboxEmails.mailbox = 'sent'
        outboxEmails.update();

}
But it seems that is not really updating to sent.

Regards,
Vaine
1 REPLY 1

vermaamit16
Kilo Patron

Hi @Rain Vaine 

 

Can you please try with below JavaScript code :

 

 

var outboxEmails = new GlideRecord('sys_email');
outboxEmails.addQuery('mailbox=failed^type=send-failed');
outboxEmails.query();
while(outboxEmails.next()) {
        outboxEmails.type = 'send-ready'
        outboxEmails.update();
}

 

Thanks & Regards

Amit Verma

Thanks and Regards
Amit Verma