Video Screencast Help

Extracting Text to different variable from a Email body

Created: 04 Feb 2013 • Updated: 26 Aug 2013 | 4 comments
This issue has been solved. See solution.


I am trying to Extract the text from our auto generated email from one of our systems in the given below formats


Employee id 000000



Name                Employeeid                          email

xxx,yyy                 000000                  

Is there a proper way to extract the name email and employee id sothat i can further process it to create a ticket.

Comments 4 CommentsJump to latest comment

reecardo's picture

The Iterate Text File Lines component will do you a lot of good here (when used in conjunction with, and not exclusively using, the Extract Text From Text component)

Your first step is to get the contents of your email into a file data type... you can do this with a Create Text File component.

Next, use the Iterate Text File Lines to navigate through your new file. In the first example above, I'd make my iteration loop check if the line started with Name (can use a Index of Text Within Text comp... if Index is 0, it starts with Name). Then trim off the Name part, and then you're left with the actual name. Rinse and repeat for the Employee ID and Email.

In the second example, again use your Iterate component. If you come to a row that looks exactly like that heading row (Name <spaces> Emp D <spaces> Email), you know your next row is going to contain the data. At that next row, you'll have to do some text handling to isolate the various parts. There are a number of ways to do this: for employee ID, you could try using a Strip Non Number Characters From Text comp on the whole line to try and isolate the employee number. For Email, you could try using an Index of Text Within Text comp to look for an @ symbol, then count a number of characters before and after to get the email (brute force basically)

etk1131's picture

I used an Extract Text By Pattern component to do this in our environment (7.1 SP1). 

If the format you're using is like the first set of examples, you can use Name as the start of the pattern, and then use Employee ID as the end pattern.  What's left should be the Employee Name.  Same method applies to the other two categories.  For the Email part, you can use your domain name as the end pattern if no other text exists in the email to use.  If you end up using the domain name, you'll have to add it back in using a Text Merge (just take the variable you specified when you extracted the user part of the email address and add to it).

Just note that in order to use the Extract Text By Pattern to work, the email must be in plain text format.  Otherwise it picks up the HTML tags, and I didn't have any luck with trying to extract based on the tags.

Hope this helps.