The Zurich release has arrived! Interested in new features and functionalities? Click here for more

jonnyseymour
ServiceNow Employee
ServiceNow Employee

An inbound email action script has access to various pieces of an inbound email through script variables. The script variables email.from and email.origemail can be different.

email.from

email.from contains an email address according to the following conditions. If the address listed in the email Headers field matches an existing user's Email address, this variable contains the user's Email address. If the address listed in the email Headers field does not match an existing user's Email address, this variable contains the address listed in the email Headers field (starting with Eureka Patch 5) or the Guest user's Email address (in versions prior to Eureka Patch 5).

email.origemail

Now, email.origemail contains the email sender's address as listed in the email Headers.

returntosender.png

Here is an example to show the difference between email.from and email.origemail

I've created an inbound email action 'Create Incident - JS', Type=New

email.from.jpg

The script is:

gs.log("-email.origemail: " + email.origemail + " -email.from: " +   email.from + " - - JS");

current.caller_id = gs.getUserID();

current.comments = "-email.origemail: " + email.origemail + " -email.from: " +   email.from + "\n\n" + email.body_text;

current.short_description = email.subject;

current.insert();

   

Then I've created a user with

-userid=test.user@abc.com, email=test3.user@abc.com

NOTE the (number "3" on the email).

2015-09-23_1529.png

Then with the user test.user@abc.com, you sent the email to the instance. Once the email is recieved, you will notice the headers contain > From:Test.User@abc.com.

inbound email action.jpg

Now, on the logs and incident comment created, you will see:

-email.origemail: Test.User@abc.com-email.from: test3.user@abc.com

2015-09-23_1536.png

More information here:

5 Comments