How to load embedded message

Hi all,

Happy new year

I have an eml file which has a .msg / rfc822 message as an attachment.

I am able to load the eml file and can see the attachment has IsEmbeddedMessage true. I want to load this embedded message as a new message and read the header values

Any pointers how can i load the attachment as a new MailMessage in .net?

I am not a developer by any means, just trying to put a quick and dirty proof of concept together

thanks a lot – Varun


I suggest you to please visit the following thread link for your kind reference.

Thanks Mudassir, i am not able to open the link it says Oops! That page is private.

Are you able to open the link ?


Can you please try again on your end.

Thanks Mudassir. I can read the post now.

I am using version 20.12

Here is the snippet of code in Powershell

Add-type “C:\\lib\net35\Aspose.Email.dll”
$FileToLoad = “c:\test\file1.eml”

$LoadOptions = new-object Aspose.Email.EmlLoadOptions
$LoadOptions.PreserveEmbeddedMessageFormat = $true

$objMailmsg = [Aspose.Email.MailMessage]::Load($FileToLoad, $LoadOptions)

The message is saved but cannot be opened in outlook


Can you please share the source EML file along with generated MSG file that fails to open. Please share the requested information so that I may investigate issue on my end.


sorry for late response, where and how do i upload the EML file, i do not see any option please advice


You can upload the source and generated files in this thread by using upload button. If the files sizes are above 9 MB, you can then upload on some file server and share download link with us.

image.png (7.7 KB)

This does not allow me to upload .EML, do i rename the eml to .jpg

Do i need to convert the EML into PDF ?


Please zip the package and share with us. (7.0 KB)

Thanks , that worked, file is attached


I have tried to extract the message attachment from EML file and extracted message attachment file is corrupt. A ticket with ID EMAILNET-40062 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Thanks, has there been any progress on this?


We have investigated the issue further on our end. The inline message is stored as EML, and when you save from an attachment, it is saved as is - in EML format. In order to save in msg format you have to load it in MailMessage and then save in msg like this:

            MailMessage objMailmsg = MailMessage.Load(path + "Sample.eml", options);
            objMailmsg.Attachments[0].Save(path + "Aspose.Save1.eml");
            MailMessage msg = MailMessage.Load(objMailmsg.Attachments[0].ContentStream);
            msg.Save(path + "Aspose.Save1.msg", SaveOptions.DefaultMsgUnicode);

thanks, is it not possible to save the attachment directly as a .msg instead of saving it as .eml first and then .msg


Actually. EML is different file format and MSG is different. The API does support converting EML to MSG file and that we have shared with you.

Thanks a lot, i will get back on this soon


Sure, we will be looking forward to hear from you.

This works well, so thanks a lot

I have one more question.

Before i save the attachment as .msg the properties of the attachment IsEmbeddedMessage is True, ContentType is message/rfc822 and TransferEncoding is Binary

When i try to add the same attachment back to the message the properties are IsEmbeddedMessage is False, ContentType is IsEmbeddedMessage is True, ContentType is message/rfc822 and TransferEncoding is Binary and TransferEncoding is Base64

Please can you advice how can i add the attachment like it was there originally