We are trying to add a large attachment of size greater than 1.5GB to a mail using aspose. But the code is getting stuck and not completing even after waiting for hours.
Providing sample code below
String name = "testFile"; // test file with size above 1.5GB (any format)
InputStream fin = new FileInputStream("src/test/resources/" + name); // if running from maven or gradle project
MailMessage mailMessage = new MailMessage();
Attachment attachFile = new Attachment(fin, name);
mailMessage.addAttachment(attachFile);
SaveOptions saveOptions = SaveOptions.createSaveOptions(MailMessageSaveType.getOutlookMessageFormatUnicode());
mailMessage.save("testFile.msg", saveOptions);
Any idea why aspose is library is getting stuck in the new Attachment object call ?
Help appreciated.
Hello @akash.sudhakar,
Email communication does not involve large-sized attachments.
Handling very large attachments can be quite resource-intensive, and Aspose.Email library is encountering memory limits.
For attachments this large, it might be worth considering an alternative method of sharing, such as providing a download link via a file-sharing service rather than attaching the file directly to the email.
Ok.
We are observing this behavior for files above 1GB size. Anything less than that, even a 999MB file finishes within 17seconds.
So is there any constraint we are keeping around 1GB in the mail creation code ?
@akash.sudhakar ,
Typically, attachments should not exceed a size of several tens of megabytes.
To transfer larger files, reference attachment is used. A reference attachment is a type of attachment that includes a link or a reference to a file or item, rather than including the file or item itself in the email message.
Please refer the doc section.