How to write email body table to excel file

Hi,
I am trying to extract table content from email body to excel file… can anyone know how to do this

3 Likes

You need to give a little bit more information but there are two ways of doing this.

  1. 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.

  2. 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,

Richard

2 Likes

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.

Regards,
Andrzej

thanks andrzej.kniola, the email is acutally look like

Hi @Sunitha_Bist,

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.

Thanks,
Vikas Reddy

1 Like

You can try this:

  1. Get the mail message using ‘Get Outlook Mail Message’.
  2. Save the email(mail message) as .eml using ‘Save Mail Message Activity’.
  3. Open the saved .eml file using start process activity.(it will open in outlook).
  4. Ctrl + A and Ctrl +C (Copy) on the email page and Paste the text into excel file.
  5. Save the excel and get the content into Datatable using Read Range Activity.
6 Likes

Hi @Sunitha_Bist,

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 :

  1. Extract the table content using IndexOf in a string by referring to the starting point
  2. Split the string on the bases on “System.Environment.NewLine” or any other as per the format
  3. Then use the individuals to be assigned to a data table
  4. Push this datatable into Excel.

Note : This will work if there is a structured logic of the table in mail (string).

Regards,
V

6 Likes

Thank you all, for your responses,

Thank you Vikas.Jain. your procedure worked out for me

1 Like

@Sunitha_Bist, Welcome.

Keep your questions coming over queries/issues.

Happy designing :slight_smile:

Regards,
V

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)

Hi @sdelvalcisneros

Try this sample workflow and let me know :slight_smile:
mailaexcel.xaml (12.0 KB)

Regards…!!
Aksh

2 Likes

Thanks@aksh1yadav I don’t know if it’s my outlook but it can’t find any body :frowning: it turns the cell in blank, what can i do?

Thanks!

1 Like

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:)

Regards…!!
Aksh

1 Like

i think it’s security from my e-mail.

Thanks you :slight_smile:

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?