How to get a recipient from a received email (distribution list)?

Victor Monteale
Tera Guru

Hi everyone, 

 

We have an inbound action that triggers when a received email contains the following recipient:

testing@service-now.com

 

However, users can also send emails to a distribution list ("dl_testing@test.com") that includes the "testing@service-now.com" and the ServiceNow Instance Email. When the email is received in ServiceNow, It does not include as a recipient nor the dl_testing@test.com email or the ServiceNow Instance Email, so the inbound action is not triggered. 

 

Do you know if there is a way to get an email direction from a received email directed to a distribution list even if this does not include the specified email in the "Recipients" field? or If there is a configuration that I must set to manage this scenario? I appreciate any help in advance.

 

Note: I reviewed all columns in the sys_email table and there is no other email direction than the email distribution list. 

1 REPLY 1

Ratnakar7
Mega Sage
Mega Sage

Hi @Victor Monteale ,

 

To handle scenarios where emails are sent to distribution lists, you might need to consider alternative approaches. Here are a couple of suggestions:

  1. Use Inbound Email Actions: Instead of relying on the "Recipients" field, you can use Inbound Email Actions to trigger specific actions based on the content or other characteristics of the email. You can define conditions and scripts to process emails based on the email content, sender, or any other relevant information.

  2. Scripted Approach: You can write a script (Business Rule, Script Include, or similar) that runs when an email is processed, and it can inspect the email's content, headers, or other properties. You might use the GlideEmailInbound API to access email properties and perform custom logic based on the presence of specific addresses or distribution lists.

Here's a basic example of how you might approach this in a Business Rule:

(function executeRule(current, previous /*null when async*/) {
    // Check if the email content or headers indicate the distribution list
    if (current.body.indexOf('dl_testing@test.com') !== -1) {
        // Trigger your desired action
        gs.info('Email sent to dl_testing@test.com received!');
    }
})(current, previous);

 

Thanks,

Ratnakar