The CreatorCon Call for Content is officially open! Get started here.

Identify target for undelivered emails

Tapish Sharma1
Kilo Sage

Hi All,

I have a requirement that whenever a notification has failed to be delivered and we recieve an 'Undelivered' bounce back email , notify certain people about that and add a link to that case. But I see that undelivered bounce back emails do not contain target or even target table . both are empty for CASE table . They do contain target or target table for ITSM tables . Is there any additional configurations we need to do so that target is set for undelivered emails on the table . Is there any configuration on tables or notifications ? Its an urgent requirement any help would be great ! 

 

 

Regards, 

1 REPLY 1

Sankar N
Kilo Guru

By default, undelivered email notifications in ServiceNow do not contain the target or target table information. However, you can configure ServiceNow to add this information to the undelivered notification email by modifying the email script.

// Get the target table and record for the undelivered email
var targetTable = email.original.getRecord().getTableName();
var targetRecord = email.original.getRecord().sys_id;

// Get the bounce reason and recipient email address from the undelivered email
var bounceReason = email.original.bounce_reason;
var recipient = email.original.recipients;

// Build the notification message with a link to the target record
var message = "Undelivered email to " + recipient + " with bounce reason '" + bounceReason + "'.";
message += "\n\nView the target record: " + gs.getProperty('glide.servlet.uri') + targetTable + ".do?sys_id=" + targetRecord;

// Send the notification email to the desired recipients
var emailRecipients = ["user1@example.com", "user2@example.com"];
gs.eventQueue("email.sent", emailRecipients, "Undelivered Email Notification", message);

This script will extract the target table and record information from the undelivered email, and then send a notification email to the specified recipients with a link to the target record.

To use this script, you'll need to create a new email script in ServiceNow and then configure the undelivered email action to use this script. You can do this by navigating to System Policy > Email > Undelivered Email and then modifying the "Undelivered Email Action" field to use your new email script.