Importing MailMessage from MemoryStream

I’m using Aspose.Network 4.2.1.0

I’m receiving the following error when trying to Import a MailMessage item into a MailMessage item via a memory stream.
“Invalid MIME foramt: header is empty.” (‘foramt’ is not a spelling mistake)

I’m writing to a memory stream using the MailMessage.Save(stream) and then using the same stream to load it into a new MailMessage using the Import function.

Sample:
MemoryStream memoryStream = new MemoryStream();
templateMail.Save(memoryStream);
templateMails.Import(memoryStream);

The templateMail headers field contains 6 entries.

Leo

Hi Leo,

Thanks for considering Aspose.

Before calling Import() method, please set the position of the stream to 0.

stream.Position = 0;