jonnyseymour
ServiceNow Employee
ServiceNow Employee

Let's talk about

  • Three simple steps to resend emails
  • If the email has attachments, how to pre-prepare them for re-sending
  • How to set the email to be ready to be sent
  • Why do we need to wait until it gets processed

Three simple steps to resend email

I'll try to cover some cases of re-sending emails from an instance.

Most cases, are straight forward. However, if the email has failed or it has attachments, you may want to consider additional steps.

There are three(3) simple steps to resend emails:

  1. If the email has attachments, pre-prepare them for re-sending.
  2. Set the email to be ready to be sent
  3. Wait until it gets processed

Send_mail_2.png

Step 1. If the email has attachments, pre-prepare them for re-sending.

If the email has attachments and it has failed (e.g. IO Message Error), please prepare them for re-sending.

If it does not have attachments, just go to the next step (2).

  1. Open each email with attachment:
    1. Save all the attachments from the email.
    2. Delete all the attachments from the email itself.
    3. Save the email record.
    4. Add all the attachments extracted previously (on step 2).
    5. Save the record.

NOTE: Exporting the XML record and re-importing back does not necessarily work.

Example to show how to pre-prepare email with attachments for re-sending

Open the email, and then go to "manage attachments".

2015-09-25_1513.png

Then save all the attachments:

2015-09-25_1521.png

Then remove all the attachments, and save the email.

2015-09-25_1526.png

Then re-attach all the emails saved previously.

2015-09-25_1529.png

Then save the email.

Step 2. Set the email to be ready to be sent

If the email has errors, fix them. Usual errors are wrong addresses, too many recipients, etc. Validate the error and correct them. Manual fixes sometimes are required.

Then set the email type to "send-ready" and save. Internally, a business rule will run.

Then re-open and set Mailbox = "Outbox" and State = "Ready". Then save.

Example of how to set the email to be ready to be sent

Set the email Type to "send-ready":

2015-09-25_1555.png

Then open each email and set Mailbox = "Outbox", and State = "Ready".

2015-09-25_1601.png

Example script to reprocess emails

An alternative example script to reprocess the emails with "send-failed", "send-ignored", and "send-ready" in all states is:

// Set queryString with the query to perform -- USE CAREFULLY

queryString = "typeINsend-failed,send-ignored,send-ready^sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)"

var gr = new GlideRecord('sys_email');

gr.addEncodedQuery(queryString);

gr.query();

while (gr.next()) {

      gr.type = "send-ready"; // this is the first update

      gr.update();

      gr.mailbox = "outbox"; // note this happen as a second update

      gr.state = "ready";

      gr.update();

}

   

Additional note: Note there is a "Resend" button if the email Type = "sent".

This is only useful if the email was sent correctly on the first place.

2015-09-25_1605.png

2015-09-25_1606.png

Step 3. Wait until it gets processed

Then if you have enabled the outbound email services, they will be resend on the next cycle.

This is usually 30-sec to 1 minute.

Hopefully they will be sent without problems.

Conclusion

Re-sending emails require three steps. If the email has attachments, pre-prepare the attachments for re-sending, then set the email to be ready to be sent and finally wait until it gets processed

Review what have your learn

After reading this blog you will know:

  • How to re-add attachement to emails
  • How to set an email to be ready to deliver
  • Where is the 'Resend' button on emails

More information can be found here:

Note: Tested in Fuji, with Chrome

3 Comments