I am using your standard way of converting MSG files to mhtml, and then trying to use Aspose.Words to convert this to images. I am having a problem with E-Mails with attachments, or big E-Mails. Aspose.EMails converts the file to mhtml totally fine, but when Apose.Words tries to open the file, it comes up with a “Out of Memory” error.
Here is the code:
Dim msg As Aspose.Email.Mail.MailMessage
Dim LoadOptions As New Aspose.Email.Mail.MsgLoadOptions()
msg = Aspose.Email.Mail.MailMessage.Load(DocFile, LoadOptions)
Dim msgStream As New System.IO.MemoryStream()
Dim msgDocument As New Aspose.Words.Document(msgStream)
Dim pngFilename As String
Dim Wordoptions As Aspose.Words.Saving.ImageSaveOptions = New Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Png)
Wordoptions.ImageColorMode = Aspose.Words.Saving.ImageColorMode.None
Wordoptions.ColorMode = Aspose.Words.Saving.ColorMode.Normal
For a = 0 To msgDocument.PageCount - 1
pngFilename = “C:\Temp” & DocumentVersionID & “.” & a + 1 & “.png”
It gives the error the line Dim msgDocument As New Aspose.Words.Document(msgStream)
This has been working totally fine for at least a year. The program has converted millions of E-Mails, so there is nothing wrong with the code. I was using an older version of Aspose.Words, so the error was a bit different. I have just upgraded to the latest version, and now the error is just “Out of Memory”.