...
Code Block |
---|
for(var i = 0; i < allAddresses.length; i++){ var address = allAddresses[i]; if(address.getAddress() === "match@test.com"){ result.setMatch(true); } } |
Matching a Regexp against a specific Email Header value
This script gathers a specific header and it will compare each of the values against a Regexp and will set the rule as a match if the Regexp matches the value.
Code Block |
---|
var headervalue = message.getHeader("X-MS-Exchange-ForwardingLoop"); //Gathers the header value/s
var regex = new RegExp("email@test.*\.com"); //Defines the Regexp that will be used to match a specific header value
if(headervalue !== null)
{
for(i=0; i< headervalue.length; i++) //Iterates over each header value
{
print("Email Header Value: " + headervalue[i]);
if(regex.test(headervalue[i])) //Checks if the Regexp matches against the header value
{
print("The Regexp matched the headervalue");
result.setMatch(true); //Sets Script Rule as a match
}
else
{
print("The Regexp did not match the headervalue"); //Displayed if the value was not matched
}
}
} |
Updating Custom Field Values via Script
...