- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 01:18 PM
We are using "Create Incident" email inbound action to create incidents from emails that will be sent out to our instance. Emails will be received from all domains (Gmail, yahoo, outlook etc.). The requirement is to read the email sender's domain and add a work notes based on his/her domain so that support group will know if it came from a known domain or not. Known domains are all the partners that are working with the company (The list is almost over 200).
I am aware that I can use if(email.from.toString().toLowerCase().indexOf('gmail.com')>=0) to read the email domain from the sender email address. Since the known domain list is over 200, how can I compare it with the known domain list what I have to see if the email came from a known domain or not? Any thoughts? Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2021 01:02 PM
I achieved it through below code:
var kDomains = ["abc.com", "xyz.com"];
var kDomains1 = kDomains.toString().split(',');
var count = 1;
for (var x = 0; x < kDomains1.length; x++) {
count++;
if (email.from.toString().toLowerCase().indexOf(kDomains1[x]) >= 0) {
current.work_notes = "[code]<p> <h3 style='color:purple; font size=5;'>" + 'Email from a Known domain'+ "</h3></p>[/code]";
break;
}
}
if (count > kDomains1.length && email.from.toString().toLowerCase().indexOf('<your organization domain') == -1) {
current.work_notes = "[code]<p> <h3 style='color:red; font size=5;'>" + 'Email from unknown domain' + "</h3></p>[/code]";
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-23-2021 01:47 PM
Hello, I'd create a system property (table 'sys_properties') to put there the domain list.
Then use gs.getProperty('your_property_name') in your script.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2021 06:02 AM
Hello
Thanks for your response. My question is how can I extract the domain from the sender's email and how can I compare it with the values in system property to see if the domain is listed as a known domain in the system property values or not? Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2021 06:31 AM
var domain = mail_from.substring(mail_from.indexof("@")); //get the values from the email sender, that goes after @
var d_prop = gs.getProperty('your_property_name'); //list of trusted domains
if(d_prop.includes(domain)){
//check if the senders domain is in list
//do what is required
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 02:22 AM