original email sender from forwarded email

Brian S5
Kilo Sage

Can anyone help me retrieve the original email address from a forwarded email into our instance. I have tried various methods posted to the community however nothing seems to pull the correct account. This is the part of code im having trouble with from my inbound email action (forwarded)  

 

sidenote: Im a super novice when it comes to javascript. just looking how to set current.caller_id as the original sender, everything else in the IEA works as it should.

var orig = new GlideRecord('sys_user');     if (orig.get('email', email.origemail)) {//if you find a user with that email, get that user's sys_id             current.caller_id = orig.sys_id;     }       current.comments = "forwarded by: " + email.origemail + "\n\n" + email.body_text;

 

Shows it was forwarded by me, rather than the original sender. I have also tried the below codes and still does not work.  

current.caller_id = email.origemail;
current.caller_id =  email.from_sys_id;

1 ACCEPTED SOLUTION

I had reached out to HI support after entering this in the community. 

 

The script they provided to help was below, i had modified it to match our requirements, but this is the base i went from. 

 

if(email.body.from != undefined) {

var user = email.body.from;

var array = user.split(/\s*,\s*/);

var ln = array[0];

var fn = array[1];

 

var gr = new GlideRecord("sys_user");

gr.addQuery('first_name',fn);

gr.addQuery('last_name',ln);

gr.query();

while(gr.next()) {

current.caller_id = gr.sys_id;

}

View solution in original post

4 REPLIES 4

Brian S5
Kilo Sage

Development update.



I was able to populate the contact field with the below part, however it didnt match the user to an actual email address and created the user account from the email.


(we have the property set to create user account from approved email domains)



current.caller_id = gs.createUser(email.body.from); (i know gs.createUser is not supported, was the only thing that has worked thus far. Im still testing various methods)


mjl
Kilo Contributor

Hi - how did you get on with your investigations? I have a similar issue.

I had reached out to HI support after entering this in the community. 

 

The script they provided to help was below, i had modified it to match our requirements, but this is the base i went from. 

 

if(email.body.from != undefined) {

var user = email.body.from;

var array = user.split(/\s*,\s*/);

var ln = array[0];

var fn = array[1];

 

var gr = new GlideRecord("sys_user");

gr.addQuery('first_name',fn);

gr.addQuery('last_name',ln);

gr.query();

while(gr.next()) {

current.caller_id = gr.sys_id;

}

wul
Tera Contributor

Hi - how did you get on with your investigations? I have a similar issue.