cancel
Showing results for 
Search instead for 
Did you mean: 

extracting text from email

Jelle_Matthieuv
Level 2
Hi everyone,

New to this program and trying to extract text from an email in outlook.

It looks something like this:
Number: Example1
Distribution: Example1
Customer: Example1
Location: Example1
and 10 more.

I want to extract all the example1 texts and past them in an excel file. What is the best course of action?

Thanks in advance
2 REPLIES 2

ewilson
Staff
Staff
Hello @Jelle_Matthieuv,

There are various ways you could do this. You'll want to start with looking at the MS Outlook VBO (latest version available on the DX).​ This will give you the ability to get the received emails from your local Outlook instance. You'll want to look at the action Get Received Items - Basic which will return a Collection of the received items that meet the criteria you provide. There are two other actions that give you a little more control, but they require some advanced knowledge of Outlook.

Once you've got the Collection of items, you'll want to loop over it working on each individual email. From there, you can access the body content of the email. Assuming the body content is plain text you could just pull the whole thing in a Text data item and then perform actions to process it line-by-line, finding the location of the ":" and then pulling out a substring from the point to the end of the string. You can perform these actions using Calculation stages and the built-in Text functions available in the Calculation stage.

If the body content of the email is in HTML format, you'll have a little more work to do as you have all the raw HTML tags to deal with. If that is the case, I'd suggest looking into the Utility - XML VBO. You could use that, along with some XPath expressions, to pull out the main text content and then use the Calculation stages, as mentioned above, to slide-and-dice the string.

Cheers,
Eric

Soumya21
Level 6
Hi @Jelle_Matthieuv

You can use ​Get Received Items - Basic action to get email details. You will get email body in item.Body field then you can use Utility String extended in that use Extract Text Field to get exact text by giving pretext and post text inputs.

If You are getting item.Body in html format the modify code in internal get items action in that replace this one line of code row("Body") = If(item.BodyFormat = 2, item.HTMLBody, item.Body) with this row("Body") = item.Body
It will fetch you email body in text. later you can use Extract Text Field action to get exact field

Thanks,
Soumya