How do I properly capture a string in an email body?

Rochelle Rona
Tera Contributor

Hi,

In an inbound email, the email template contains "Process the request from test@test.com". I need to capture the email.

I have the code "var reqEmail = email.body.process_the_request_from" and have it set to the short description but it's returning undefined.

13 REPLIES 13

Sourabh26
Giga Guru

Hi,

 

Use the below logic.

 

var template = "Process the request from test@test.com";

var splitStr= template.split('from'); ['Process the request from', 'test@test.com']

var emailAdd = splitStr[1]; //test@test.com

 

You can add this emailAdd to the description on any other fields in your table.

 

Mark this as Correct/Helpful in case this helps you in anyways.

 

Regards,

Sourabh

Hi Sourabh,

 

I tried your codes above but it did also captured the remaining texts of the email body.

var str = email.body_text;
var splitReqEmail = str.split('from');
var reqEmail = splitReqEmail[1];

Hi,

 

For me its working fine. See below

 

Script - 

find_real_file.png

Output - 

find_real_file.png

 

Can you share the screenshots for the same.

 

Regards,

Sourabh

Hi,

Yep, this will work because it's a specified variable for the whole string. For my case, I have the whole email.body_text that contains other information apart from ['Process the request from', 'test@test.com'] That's why it's still capturing texts after the email part.