We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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