whitin the project I am working on I need to save within variable with type System.Data.DataTable data from the table placed within the Outlook e-mail message body. I have not found the way how to do it.
Table is simple - there are 6 columns, 4 rows, no merged cells.
So, I will be thankfull if someone can advice how to do it.
- Save the mail as WebPage(In outlook you can save the mail as a file then open it and use save as)
- Open the saved WebPage
- Then extract the data using extract datatable
Not sure how you can do it if you’re not using outlook.
akhi_s27 thank you for your answer!
I have already tried following:
- saved mail message as html file using UiPath.Mail.Activities.SaveMail
- opened saved html file using UiPath.Core.Activities.OpenBrowser
As a result of this html file is being opened but it do not look like e-mail message - table is deformated. It looks like html elements are not presented correctly. So, unfortunately opened html cannot be used to scrape data table. As I am new user it looks like in the forum I cannot upload files to add an example of how html is being opened by UiPath.
akhi_s27, have I understood correct that steps I made are steps you proposed?
Maybe there are solution for this or another way how to extract data table from e-mail body?
Interesting that if I am manualy in Outlook saving mail message as html file and then opening the file in IE, html file is being opened correctly - such html could be used for data table scraping. So, the problem with correct saving/opening of html is only if it is being done by UiPath.
Anybody have ideas why it is so?
Hi VladisG did you find the solution I have same issue …
Hi, hkjobs1988, no I have not found solution.
One expert adviced me following via e-mail - “I looked at the problem – and I couldnt get the save email to save the email in a resonable html format. You can however open outlook, open the mail and save to html – that will be in a perfectly readable format.” I have not tried yet, but going to try.
If you or someone else found solution please let me know here.
Can you change the data and attach the mail message here?
as I am new user it looks like in the forum I cannot upload files.
I have example mail message, but how can I share it with you?
Any solution for this
Hi @VladisG @Kamesh , i had the same issue, and the only way to do it was to save the mail message with the extension *.mht (wich i discovered was a web page format for IE).
The datable is no longer disorted (only some typo due to the US encoding for French character).
ExtractHTMLTableFromEmailBody.xaml (10.0 KB)
Please find the sample workflow to extract Table from the Email body.Let me know if you are facing any issues.
Thanks! for sharing the xaml file it is useful but only thing in we are not able to save extracted data into .xls file or message box is coming as empty.
i have followed the exact solution u have shared.
pls share the solution i want the data to be saved as xls or csv file.
any fix is welcome.
Thanks in advance
I have downloaded the above ExtractHTMLTableFromEmailBody.xaml file after running message box returned as empty, pls let me if any modification required to be done xaml file.
This issue needs to be fixed ASAP, pls let me know the solution.
I had issues with extracting data using the above method and the issue was not with the XAML but rather with y IE settings.
After checking in Internet options under the advanced tab it all started to work for me.
If you have Excel license then you can save your message as EML file (by using Save Mail Message) and read your file within an Excel Application Scope, just like reading an xlsx file. The workbook path of the Excel Application Scope would be something like “mail.eml”
You will have to map the table based on the headers, but that’s easy.
Can you try this:
Can you try below apporach.
1>get outlook mail message - filters are supported here.You can search through other posts on forum.
2>loop through the list to work on required email.
3>for the required email get the item.Headers("HTMLBody”).ToString
and store into a string variable using assign.
4>Now run the custom activity RPA Components - Bundles, Integration Packs | UiPath Marketplace On this html string to get the data tables which you can write into excel pr can directly iterate through.
All of this will happen in background👍
how to add email metadata into datatable
datatable columns : subject(String), body(String), attachmentName(String)