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

Free Support Forum - aspose.com

Out Of Memory Exception when storing large attachments to pst

I have the following code to generate emails & store in a pst file. When the total size of attachments in the folder is more than 170MB I get an Out of memory exception when adding the message to PST Folder…

public static void Main(string[] args)
if (File.Exists(DestinationPstFile))

using (var storage = PersonalStorage.Create(DestinationPstFile, FileFormatVersion.Unicode))
var pstName = Path.GetFileNameWithoutExtension(DestinationPstFile);

var folder = storage.RootFolder.AddSubFolder(pstName);

var attachments = Directory.GetFileSystemEntries(FolderWithAttachments);
var mailMessage = new MailMessage
To = "recipient@test.com",
From = "sender@test.com",
HtmlBody = “\r\n\r\n \r\n Text \r\n”,
Date = DateTime.UtcNow,
MessageId = “test”

foreach (var attachmentFile in attachments)
var attachment = new Attachment(attachmentFile);
using (var mapiMessage = MapiMessage.FromMailMessage(mailMessage))

Hi Babu,

Could you please confirm to us if you are using the latest version of Aspose.Email for .NET in your application? I have tested this issue at my end using the latest version of Aspose.Email for .NET 4.1.0 and I am afraid to share that it didn’t give raise to any exception. Could you please try it with this latest version and let us know your feedback for further assistance? Reference screenshot of generated PST with 200+ MB attachments size is as attached with this post.