Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Amit Verma
Kilo Patron
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


Please mark this response as correct and helpful if it assisted you with your question.