I am trying to extract table content from email body to excel file… can anyone know how to do this
You need to give a little bit more information but there are two ways of doing this.
The best way is if you have the Email Body from a Mail Activity such as Get Outlook Messages. In this case it is simple because the .body property of a MailMessage object can be converted to string and can therefore just be output directly to Excel using Write Cell. Alternatively if you have a bunch of mailmessages you could create a datatable and then output the full datatable to Excel using the Write Excel activity.
If you are using UI (i.e. you are scraping the text from the email) then the priniciple is the same. Convert the generic value to string and export it to Excel.
Hope that helps,
Thanks for your response Richard
i need the 1st way of extracting table but the problem is at string… whole body content is extracted by a string… if i use write cell then in a single cell itself all body content gets placed… i need table like format in excel file also…
Im having one more doubt, how to create excel file… if I use create file option it is showing error as excel format is wrong… if anyone knows please help me
Excel write activities will create a new excel file if you point to a file that doesn’t exist.
For the formatting - you’ll need to parse the content to columns as you need. This may be simple or pretty complicated, depending on how the emails actually look like.
Actually you cannot write a string into an excel (as table) though there is a table in it.
You have to work in splitting your string according to space, newlines until we get the required table out of it.
You can try this:
- Get the mail message using ‘Get Outlook Mail Message’.
- Save the email(mail message) as .eml using ‘Save Mail Message Activity’.
- Open the saved .eml file using start process activity.(it will open in outlook).
- Ctrl + A and Ctrl +C (Copy) on the email page and Paste the text into excel file.
- Save the excel and get the content into Datatable using Read Range Activity.
Looking at the example you have given, first you need to read the the Outlook Body mail and then use string manipulation in the below order :
- Extract the table content using IndexOf in a string by referring to the starting point
- Split the string on the bases on “System.Environment.NewLine” or any other as per the format
- Then use the individuals to be assigned to a data table
- Push this datatable into Excel.
Note : This will work if there is a structured logic of the table in mail (string).
Thank you all, for your responses,
Thank you Vikas.Jain. your procedure worked out for me
Keep your questions coming over queries/issues.
Hi Sunitha, can you share your xaml file? Thanks!
@sunitha_Bist i will like to have it to…
Im trying something similar and it doesn’t work!
If someone else wants to help. I want to make it easier i want all the content of the body from an email in a excel row, then i will convert the excel information with other procedures.I attach it if someone wants to help me mailaexcel.xaml (8.1 KB)
Try this sample workflow and let me know
mailaexcel.xaml (12.0 KB)
Thanks@aksh1yadav I don’t know if it’s my outlook but it can’t find any body it turns the cell in blank, what can i do?
It is really strange for me it is coming. i really have to debug many of others also not getting this but for me it is coming.
before you were getting? if it is so then just add some code after that or let me know:)
i think it’s security from my e-mail.
Can you share xaml file please
Hi How to write email body content to excel ? Thanks
Sunitha, can you share the xaml file for this?