- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2018 01:58 PM
Hi,
I have an inbound action which I have configured, but there is one part that I cannot do and was wondering if it was possible to do or if anyone could help?
We basically get an email where in the email body it has "The following user: Jane Doe is.."
I basically want to be able to pull whatever is between user: and is into a variable to get the persons name, is this possible?
Cheers,
Nabeel
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2018 03:00 PM
I would use a regular expression for this just to make. Your code will look like this
var match= /.*:(.*)\sis/g.exec(str)[1].trim(); //str is the variable that is decalred to store the string

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2018 02:11 PM
try something like
var user = email.body.user.split(":").toString();
var name = user[0].split("is").toString();
var final = name[0];

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2018 02:11 PM
Yes, this is possible.
you will to use javascript string methods to extract information from email body in variable.
https://www.w3schools.com/js/js_string_methods.asp
Please follow below sample code to find index of your keywords and use another string function to store value in variable
str1 = email.body_text.indexOf("%user:");
str2 = email.body_text.indexOf("is");
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2018 03:00 PM
I would use a regular expression for this just to make. Your code will look like this
var match= /.*:(.*)\sis/g.exec(str)[1].trim(); //str is the variable that is decalred to store the string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-02-2018 03:19 PM
Worked perfectly, thank you so much!!