We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Out of Memory when opening mhtml files

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()
msg.Save(msgStream, Aspose.Email.Mail.SaveOptions.DefaultMhtml)
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”
msgDocument.Save(pngFilename, Wordoptions)
Next

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”.

@runrobert

Please ZIP and attach your input MSG file here for testing. We will investigate the issue on our side and provide you more information.

So I spent the whole day trying to get this working. When I tried to find a file specifically that doesn’t work just now, I found that everything is working. When I logged in, there was a message saying that some updates had been run in. So it appears that the error was actually a Microsoft error that was patched. I assume the patches only get run in on Friday night, which is why I have been battling with this for the week.
So it appears that this is fixed. I will know on Monday when the users start trashing the system.

@runrobert

It is nice to hear from you that you have found the root cause of this issue. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Hi,

I am afraid that I am still having problems. It seems the first problem I had was to do with fetching the blob from SQL. It would cause a memory error that would cause everything else to have memory errors, thus I couldn’t replicate it. I have found the following E-Mail that won’t go through the process. It now bombs on the Dim msgDocument As New Aspose.Words.Document(msgStream) statement, saying that the parameter is incorrect. Not sure what this is, as I don’t have any parameters here.

Regards
Robert
Here is the MSG file, plus the mhtml file that it generates. I have tested trying to open the mhtml file directly, instead of using the memory stream. This doesn’t work either.
MSG.zip (163.6 KB)

@runrobert

We have tested the scenario using the latest version of Aspose.Words for .NET 19.5 and have not found the shared issue. So, please use Aspose.Words for .NET 19.5.