Getting Recipients data from the Mail

Sagar Rd
Tera Contributor

Hi All,

 

I am working on a inbound action and I was trying to fetch the details of the recipients from the email. When the inbound action was in global scope the recipients details were fetched properly but when it is in the HR Scope it did not fetch the results. Could you please help me what would have caused the issue and how can I fix it.

Script when the Inbound action is in Global Scope:

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var all_mail = email.recipients;
gs.log("All Mail from Global"+all_mail);
    // Implement email action here

})(current, event, email, logger, classifier);
 
 
Script in the HR Scope:
 
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var all_mail = email.recipients;
gs.log("All Mail from HR"+all_mail);
    // Implement email action here

})(current, event, email, logger, classifier);
 
Results are fetched only in the Global scope, I have checked both the Inbound action are processed. Please help me.
 
Thank You
2 REPLIES 2

Runjay Patel
Giga Sage

Hi @Sagar Rd ,

 

You can use email.copied instead of email.recipients.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

In this video i have explained about Web service integration in ServiceNow like how it works, how we can configure it, what are the prerequisite and many more. I have covered below topics in this video. 1. understand Web Service. Like when and how we will use it. 2. Talked about Inbound and ...

Runjay Patel
Giga Sage

Hi @Sagar Rd ,

 

FYI,

 

email.copiedContains a comma-separated list of email addresses in the Cc: box.
email.recipientsContains a comma-separated list of recipient addresses as a plain text string, in the To: box.
email.recipients_arrayContains the recipient addresses as an array.

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

In this video i have explained about Web service integration in ServiceNow like how it works, how we can configure it, what are the prerequisite and many more. I have covered below topics in this video. 1. understand Web Service. Like when and how we will use it. 2. Talked about Inbound and ...