Get the subject and the body of a .msg/.eml file in HTML

Hello,

I need to get the body and the subject of an .msg/.eml file, but the problem is that some of the emails contains a table in body and I would need the body in HTML, because after that I need to send another mail with that body.

I tried a lot of methods from the forum, but none of them works.

Thanks in advance!

Hi @darie.leolea

You can launch the .msg file by using use application\browser activity.
Inside of Use application\browser activity use the Extract Datatable activity to extract the table from mail and store in a datatable.

Hope it helps!!

Hi @darie.leolea

When you run a For each through the list of MailMessages you can use the below syntax to get the vbody in HTML

BodyAsHTML= currentItem.BodyAsHTML.ToString
Subject = currentItem.Subject.ToString

Regards

1 Like

I receive this error: Object reference not set to an instance of an object.

@darie.leolea

Can you share the screenshot of the error.

Regards

@darie.leolea

What is emailnet variable can you share the workflow process.

Regards

ss_2

Hi @darie.leolea

Since emailnet varaible type is of List(MailMessage). You need to run a for each loop to iterate through the mail messages and inside the loop use assign activity and give the below syntax.

Happy to help if you face any difficulties.

Regards

The problem is that i don’t read them from Outlook. I have a folder with .msg mails and i read them with for each file in folder. Is there a way to add them to a list of MailMessage so I can use your method ? Thanks!

Hi @darie.leolea

Please use the below workflow:

Regards

Hi @darie.leolea - you need to read the file from the windows folder this below helps you.

Even if I use this method, the string which should read the body is empty

Even if I use this method, the string which read the body is empty.