Convert .eml to .msg


#1

Hi Team,

I am trying to convert .eml to .msg format and upload the .msg to our document management system(LiveLink).

When I download and save the file[ from(.eml)/to(.msg) ] in disk and upload to LiveLink it works fine but when I convert and save as stream no error from aspose but our document management system is unable to recognize the format .

Please refer to the below format [.net framework 4.5]

Stream stream = new MemoryStream(emailMsg.MimeContent.Content);

MemoryStream msgstream = new MemoryStream();

Aspose.Email.Mail.MailMessage objmessage = Aspose.Email.Mail.MailMessage.Load(stream, MailMessageLoadOptions.DefaultEml);


objmessage.Save(msgstream,MessageFormat.Msg );

Can you please check and revert to me what is the issue .


#2

Hi Muru,


Thank you for writing to Aspose support team.

There doesn’t seem to be any such issue and the code looks fine. Please try positioning the stream to 0 before the document is provided to the LiveLink. In case the issue still persists, please provide us with your sample EML file for our investigation. We may also need some sort of access to LiveLink for reproducing this issue at your end. We’ll look into it for assisting you further.


#3

stream.Seek(0, SeekOrigin.Begin);


…is your friend if you need to process the stream twice, i.e. save to disk then upload somewhere, I had the same issue trying to process the attachment.contentStream twice, second time failed until I rewound the stream.

Si

#4

Hi Simon,

Indeed, the used stream can not be used again and it is invalid if it is tried to be used again. The stream needs to be positioned at the beginning before it could be used again.