Inbound Email - Getting original email address

lrenninger
Kilo Explorer

I am in the process of writing a script for an Inbound Email Action, but I am having an issue.

The script is meant to assign incidents to specific groups based on the from address on the inbound email. I'm running into trouble because the email.fromand email.origemail variables are both returning a name as opposed to an email address for some of the email addresses. There are some scripts in the instance that are using gs.CreateUser() and making users from inbound emails, which I think is part of what's causing ServiceNow to return a name as opposed to an email address.

I assume they're supposed to work this way for some reason, but is there any way to just read the actual email address (user@domain.com) as opposed to a name (User Name) in all cases? It stands to reason that it has to be accessible (since gs.createuser makes a user using the email address from inbound emails) but I can't find anything in the wiki that gives me any sort of clue how to do it.

6 REPLIES 6

dmartinc
Tera Expert

I do not know why it does not work for you. For me, email.origemail returns the "From" address, not the user... Are you 100% sure this is happening to you?
If it helps, in our instance the property "Automatically create users for incoming emails from trusted domains" is set to false.\
Cheers,
David


Vaughn Romero
ServiceNow Employee
ServiceNow Employee

The wiki has the warning that both email.from and email.origemail:

"[contain] the email sender's address as the instance lists it in the User (sys_user) table, regardless of the source email address."

It could be that these users do not have email addresses listed in their user records.


Hello Vaughn,

I think that is an old version of the wiki. Now the difference between email.from and email.origemail is clear:
http://wiki.service-now.com/index.php?title=Inbound_Email_Actions#Accessing_Email_Objects_with_Variables
And that is how it works in my experience...

Cheers,
David


lrenninger
Kilo Explorer

When I insert email.from and/or email.origemail into a field it's inserting a name followed by an email in parentheses, which is what caused me to suspect that was the problem. It is completely possible that it's doing that for display purposes somehow, but it's also not hitting the correct portion of the if...else loop in my script for my test email address which makes me think it's not limited to just the display.