Exception: OutofMemory on saving MSG file (C# .NET)

Dear Team,

We are using Aspose.Email references in my project.
We are reading the message file(.msg file) and getting the all required properties like sender, body,To and CC fields.

Now we have a message file with size of 95MB. but when i am using below code, i am getting system out of memory exception.

using (MemoryStream mailStream = new MemoryStream())
{
AsposeEmail.Mail.SaveOptions so = new AsposeEmail.Mail.MhtSaveOptions();
this.mailMessage.Save(mailStream, so);
}

While exicuting the save option i am getting the error.
Could you please tell me how much size of data that we can save.?

Thanks,
Siva

@sivasadhu,

I have observed your comments. Can you please share source file so that we may further investigate to help you out.

Hi @Adnan.Ahmad,

Thanks for the response,

I tried to share the email file which is having 95MB size, but this portal is not allowing me to upload the file.

Below is my sample code that i am using in my application.

AsposeEmail.Mail.MailMessage mailMessage = AsposeEmail.Mail.MailMessage.Load(this.inputStream);

In above line, I am reading my input file as a Stream.

after that i am using below code.
using (MemoryStream mailStream = new MemoryStream())
{
AsposeEmail.Mail.SaveOptions so = new AsposeEmail.Mail.MhtSaveOptions();
this.mailMessage.Save(mailStream, so);
doc = new AsposeWords.Document(mailStream);
}

During the execution of the save i am getting system out of memory exception.

Kindly verify and let me know if you need any details from my side.

Thanks.

@sivasadhu,

Can you please share source file via Dropbox so that we may further investigate to help you out.

Hi @Adnan.Ahmad,

Kinldy access below link. Here i uploaded my email file.

Thanks,
Siva.

@sivasadhu,

I have tried accessing the shared message file on my end and have observed no issue. I request you to please try using x64 based solution project on your end and then try accessing the Message file. Hopefully, you will not receive any error with this.

Dear @mudassir.fayyaz,

Thanks for your response. I will try to use the x64 based solution project and let you know the details.

Thanks,
Siva

@sivasadhu,

Please share with us if there is still any issue incurring.

Dear @mudassir.fayyaz,

I have tested the application with x64 solution project and it is working as expected.
Thank you so much for your help.

Thanks,
Siva.

@sivasadhu,

It’s good to know that suggested options have worked on your end.