- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 07:45 AM
Hey all!
I'm working on setting up some inbound email actions so that our Service Desk can forward emails to our system and have it auto-create certain requests. I've got an inbound email action that will go thru and create a Password Reset Request and it works great with Plain-Text formatted emails that are sent. But as soon as I use HTML formatted emails, then I run into issues.
Because these emails are going to be forwarded by our Service Desk techs, I want to have them to have a variable that they will put in the email address of the account that needs to have the Password Reset done. I have the inbound action set to find and pull out that email address and will look up the account and create the request for that account.
The issue I am having though is that when a HTML formatted email is used, the script pulls the email address as a string that is formatted as username@oneonta.edu<mailto:username@oneonta.edu> and that is causing issues when looking up the account.
I tried removing the hyperlink info before sending, but Outlook/Microsoft must add it back in the sending.
Does anyone have any thoughts about how I can either just pull in the username@oneonta.edu or if there is a way that I can parse out the <mailto:username@oneonta.edu> html tag?
Action script for finding the Requested For email address:
if (email.body.requested_for != undefined)
{
gs.log("PSWD_Reset_Request_IA::Found requested_for in email body");
var pw_requested_for = email.body.requested_for.trim();
var grUser = new GlideRecord("sys_user");
grUser.addQuery("email", pw_requested_for);
grUser.query();
if(grUser.next())
{
gs.log("PSWD_Reset_Request_IA::Found user based on email");
//current.caller_id = grUser.sys_id.toString();
cart.setVariable(item, 'reqUser', grUser.sys_id.toString());
}
else
{
gs.log("PSWD_Reset_Request_IA::Couldn't find user based on email");
//current.caller_id = "9b4d21a20f848600719e6798b1050ea6";
cart.setVariable(item, 'reqUser', "9b4d21a20f848600719e6798b1050ea6");
}
}
Sample variable input from email:
Requested_for: Emmon.Johnson@oneonta.edu
Sample output when the Request is created:
Requested_for: Emmon.Johnson@oneonta.edu<mailto:Emmon.Johnson@oneonta.edu>
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 07:53 AM
Hi, You could use the following to check if the body variable contains mailto: and if so, split the variable into the properties you want. Other than that, you'll most likely need to dive into regex.
if (email.body.requested_for.indexOf('<mailto:')){
var pw_requested_for = email.body.requested_for.split('<mailto:')[0]
} else {
var pw_requested_for = email.bosy.requested_for.trim();
}
If my reply helped with your issue please mark helpful 👍 and correct if your issue is now resolved. ✅
By doing so you help other community members find resolved questions which may relate to an issue they're having.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 07:53 AM
Hi, You could use the following to check if the body variable contains mailto: and if so, split the variable into the properties you want. Other than that, you'll most likely need to dive into regex.
if (email.body.requested_for.indexOf('<mailto:')){
var pw_requested_for = email.body.requested_for.split('<mailto:')[0]
} else {
var pw_requested_for = email.bosy.requested_for.trim();
}
If my reply helped with your issue please mark helpful 👍 and correct if your issue is now resolved. ✅
By doing so you help other community members find resolved questions which may relate to an issue they're having.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 08:04 AM
Thank you very much!
My javascript is very rusty so thank you so much for your assistance. This worked like a charm!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2020 08:12 AM
Ah glad it worked, you're most welcome! 🙂