How to read email body in excel data table

Hi Everyone,

I’m having a hard time with my code. I’m trying to read data from the body of the email and match them to the data in excel. I’m new to this and would greatly appreciate any advice or suggestion to changes.

MainMail.xaml (422.4 KB)

Just noticed, why is your mailMessage variable in " " [quotes]
To get the body, you need to use, mailMessage.Body.toString

Once you do that you can extract the key you want from the body and match with your excel data row/column

Hi Nadim,

Thank you so much for your help. I’ve changed my value to mailMessage.Body.toString but I’m still getting and issue. Do you think you can help me out again?


Thanks,

Nadim,

I figured it out! Thank you! I’m now trying to figure out my variable types. I keep getting this error below. I believe I’m not using the proper variable type but I will try to find the issue thank you again!

System.NullReferenceException: Object reference not set to an instance of an object.
at UiPath.Core.Activities.ForEach`1.Execute(NativeActivityContext context)
at System.Activities.NativeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)

1 Like

Great! Way to go and you got it right. Its the type of the variable and the same will apply in the foreach as well

Hi Nadim,

Can you tell me what I did wrong? System.Char is it because I’m still trying to covert system.net.mailmessage to a string?


where are you doing this conversion?

1 Like

Hi Nadim,

I’m no longer getting an error but I’ve noticed that my infinite loop is not working. So the email contains responses that is in the excel file. But instead of moving the email once the body of the email contains the same data in the excel file it continues to execute. The only way the email was moved to research folder is when the email address is found in another excel data table. I’ve attached my main for your reference. I’ve really tried to resolved this and now I’m puzzled…

Since there are only 3 sentences to check if its in the body of the email I’m almost close to just writing 3 if statements instead of referencing a table :expressionless:

Logs

Main.xaml (424.8 KB)

You will need something like this.
But here your column name has to be added so that column value can be matched

image

2 Likes

Hi Nasim,
Thanks so much! That worked! last thing I have to do now is work on my variable type since I’m still getting the object reference not set to an instance of an object. Hopefully I can figure this out and close my case. Thanks so much for your help! I’ts been really helpful since I’m a noob :smiley:

1 Like

Hey, no problem.

Actually just check its some value that is not getting set.
Hence its null when it being used.

If you debug youll get the it or you can just print your variables :slight_smile:

[Please close this thread marking answer as solution]

Custom activity to extract tables from email:
https://go.uipath.com/component/extract-tables-from-mail-839f39
It takes mailmessage as an input and returns a dataset with all the table content in the email.