Extracting string from body email


#1

Hello friends,
I need to extract the 4 strings located after the words: BUSINESS OPERATIONS (at the end of the email body).


How it it possible to search for 4 the words located in the 4 diffeent lines after the string BUSINESS OPERATIONS?
Thank you so much,
Camilla :slight_smile:


#2

Hi! Did you tried using Screen Scraping?


#3

Thank you @Niket_Ghai.
I thought It would be more reliable to use the Regex Expressions.
Can you please help me?
Thank you,
Camilla :slight_smile:


#4

That’s true. So are you extracting the whole body and then are you trying to filter out the email?


#5

Yes exactly :slight_smile:


#6

You can split the body of mail by “BUSINESS OPERATIONS” and take the secord array item.
Again then split by your name and take first array item (if you are the sender always)


#7

screen scrapping is not required read the message body using MailMessage.Body to get entire text to a variable.

hope this is not required. split the second array item by Environment.Newline and take the first four array items if the pattern is same for all the mails.

Thanks,
Pathrudu


#8

Thank you @pathrudu.
Can you please give me the example of how to extract the first word?
Thank you so much,
Camilla. :slight_smile:


#9

Hi,
change the folder name change index numbers as per your requirements. hope this may help you.

FetchDataFromMail.xaml (10.2 KB)

regards,
pathrudu


#10

Thank you so much @pathrudu.


It works but the output of the first string that should be extracted is empty:

Can you please help me a little bit more?
Thank you so much,
camilla :slight_smile:


#11

There is a new line after Business Operations, so use 2,3,4,5 the items. :slight_smile:


#12

this will work only if the pattern of your mail is fixed else you need to check for length of each item if its zero go for the next item till you got four entities.


#13

Thank you so much @pathruduI ask you a little question.
In case I get the date in the format “ddMMyyyy”, how is it possible to manipulate in order to insert the “/” separator?
Thank you so much.
Camilla :slight_smile:


#14

Main (3).xaml (5.5 KB)
This might help you to change the date :slight_smile: