Velocity - Validate recipients email address and set custom field accordingly
Velocity - Validate recipients email address and set custom field accordingly
This example performs a search against the recipients in the To and Cc headers for specific email address domain and set the value in the custom field Internal or External based on that email address. For example, @aaa.com is internal email address and @bbb.com is external and if the incoming email contains any of email addresses with @bbb.com in the To or Cc it will set the custom field to External or vice versa.
#set ($catchAddress = $jemhUtils.getCatchEmailAddress().getAddress())
#set ($finalValue = "internal")
#foreach($address in $toAddresses)
#if(!$address.getAddress().toLowerCase().endsWith("@bbb.com") && !$address.getAddress().equalsIgnoreCase($catchAddress))
#set ($finalValue = "external")
#end
#end
#foreach($address in $ccAddresses)
#if(!$address.getAddress().toLowerCase().endsWith("@bbb.com") && !$address.getAddress().equalsIgnoreCase($catchAddress))
#set ($finalValue = "external")
#end
#end
$finalValue
, multiple selections available,
Related content
Velocity Script Custom Field Defaults
Velocity Script Custom Field Defaults
Read with this
Setting a custom field value
Setting a custom field value
Read with this