Really big attachments restrictions

Hi guys,


we have kind of situation. We have to process really big MSG files and write it to the PST files but this line of code is throwing OutOfMemotyException:

MapiMessage.FromFile(testMsgFilePath)

Is there any restriction how big can the message or attachments be? Is there any difference if running 32 or 64 bits? I’m talking about 300 MBs attachment but sometimes also smaller ones are failing.

Thanks a lot!
Marek

Hi Mark,


I have tested this issue on both 32 and 64-bit operating systems but was not able to observe the OutOfMemoryException. Aspose.Email for .NET 5.0.0 has been used during my testing with the following sample code where each attachment was 100+ MB. I would request you to try it with this latest version and share your feedback with us.

If the issue still persists, please provide us some sample data in the form of messages that we can use to investigate this issue in detail.

MailMessage mailMessage = new MailMessage();
mailMessage.Attachments.Add(new Attachment(“LargePst.pst”));
mailMessage.Attachments.Add(new Attachment(“LargePst.pst”));
mailMessage.Attachments.Add(new Attachment(“LargePst.pst”));

MapiMessage mapiMessage = MapiMessage.FromMailMessage(mailMessage);

Regards,
Muhammad Waqas

Hello Muhammad,


I created test message with two gig attachments with this code:

var message = new MailMessage
{
From = from,
To = to,
Subject = subject
TextBody = body
};

foreach (var attachment in attachments)
{
if (File.Exists(attachment))
{
message.Attachments.Add(new Attachment(attachment));
}
}

var outlookMsg = MapiMessage.FromMailMessage(message);
outlookMsg.Save(strMsgFile);

After that I tried to write this MSG to the PST file with demo project which is in the attachment.
I tried several times and exception is thrown every time when adding message to the store.

Can you please verify?
Thanks a lot!

Hi Mark,


The PST class is meant to hold messages that are communicated over network. As can be seen from here, the maximum message size servers support is 10MB which has been specified keeping in view the server side communication and storage limitations. Moreover, since the message files are loaded completely in memory, such large size messages can lead to unexpected behavior. For example, I created such a PST with the 1 GB message file and Outlook went into indefinite situation opening it. Thus, unlike normal database, a messages as well as a PST file can’t hold such large amount of data for regular operations of these.

Regards,
Muhammad Waqas

Hi Muhammad,


all right so I have to add 10GB attachment restriction.

But to be sure, is there any other way how to add MSG file to PST file (maybe without loading into memory) which would allow even bigger attachments?

Thanks a lot!
Marek

Hi Marek,

The message needs to be loaded first completely in order to add it to the PST. There isn’t any other such method available that can allow adding such bigger size messages without doing so. You can find more information about adding messages to PST from our documentation article Add Messages to PST and let us know if we can be of any additional help to you.

Regards,
Muhammad Waqas