How do I extract specific text from mail body

I want to extract specific text from mail body. Capture
I want to get the numbers in blue and store it in a variable. But whenever I try to print mail body it always gives blank output.

Hi @shrutika

you can use a split function on your Subject your expression will look something like this :

item.body.Split({"Total number of new prospects imported: ","Total number of previously existing prospects that were updated: "}, StringSplitOptions.None)

use this in an assign activity and create a variable which will be an array of strings (string[]) and it will contain your numbers.

Regards,
Reda

@reda, those are good tips! but think the problem is that the data is in the body and item.body is returning blank output.

Personally, I would output both item.Subject and item.Body outside the if condition just to make sure you are looking at the right information, for troubleshooting. When you can confirm the Subject line and Body are what they should be from the output of every mailmessage, then you can solve for it.

I thought he is trying an other way to extract the numbers and it is not shown in the screenshot and he gets an empty output.

@shrutika I would definitely try ( as@ClaytonM has suggested ) to loop without condition if I were you.

Make sure that the split is well made and you have your desired output and then the only problem should be with the condition (meaning the subject of your messages don’t contain the exact word “Import Successful” )

I tried what you have suggested. I am getting correct subject, but output of item.Body is always blank

Hi @shrutika

Does this post help you by any chance?

1 Like

Thank you. This was the exact problem that I was facing- mail body had html content. This post helped me resolve it.
item.Headers(“HTMLBody”).ToString

1 Like

Awesome! All credit goes to @saikumar1 for this one :slight_smile:

Hey welcome guys! Glad I could be of help, still learning this wonderful tool.

I am not sure who can, but can someone get the tutorial updated for this bit please, because its really crazy sometimes when you do everything as prescribed and things dont work.

Hey @saikumar1

Could you just clarify which tutorial you have on your mind? I am not sure I get it from the context :slight_smile:

Sure,

This is the one, it just doesn’t work out of the box.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.