Aspose_Issue.zip (9.1 KB)
Hello team, We have observed that Aspose.Email.MapiMessage.load
method will throw an error for some emails while loading the inputStream of its MIME content.
MapiMessage mapiMessage = MapiMessage.load(inputStream, new EmlLoadOptions());
Above code will throw an error in below scenarios,
-
Emails with large size(greater then 400 MB), will throw java.lang.OutOfMemoryError: Java heap space
error.
-
Emails having some html content not enclosed within the <html>
start & end tag, will throw com.aspose.email.system.exceptions.ArgumentOutOfRangeException: startIndex + length cannot exceed length of string
error. (Please find the attached zip having sample email causing this issue)
Error Trace:-
class com.aspose.email.system.exceptions.ArgumentOutOfRangeException: startIndex +
length cannot exceed length of string.
Parameter name: length
com.aspose.email.internal.b.zar.b(SourceFile:1949)
com.aspose.email.zacc.j(SourceFile:603)
com.aspose.email.zacc.a(SourceFile:136)
com.aspose.email.MailMessage.getHtmlBodyText(SourceFile:2064)
com.aspose.email.MailMessage.getBody(SourceFile:898)
com.aspose.email.zatp.a(SourceFile:960)
com.aspose.email.MapiMessage.h(SourceFile:4623)
com.aspose.email.MapiMessage.a(SourceFile:3476)
com.aspose.email.MapiMessage.b(SourceFile:3054)
com.aspose.email.MapiMessage.fromMailMessage(SourceFile:1783)
com.aspose.email.MapiMessage.b(SourceFile:1479)
com.aspose.email.MapiMessage.a(SourceFile:1446)
com.aspose.email.MapiMessage.load(SourceFile:1440)
Can you please let us know what is the cause of error and how to handle it.
Hello @SudhanshuPanwar,
- In fact, email is not expected to send large messages. So, the MailMessage class was developed on the basis of this feature. It loads the whole message to the memory considering that the message is not larger than some dozens of megabytes.
Many email servers and clients have limitations on the size of attachments that can be sent or received.
Most email providers, including Gmail, Yahoo Mail, and Outlook.com, have a file attachment limit of 25MB. Some email clients, such as Microsoft Outlook, allow users to send larger attachments but they use a cloud storage service like OneDrive or Dropbox. Sending very large email attachments can also cause issues with network bandwidth and slow down other email traffic. In addition, large attachments may be rejected or blocked by the recipient’s email server, especially if they are sent to multiple recipients or to a large distribution list.
On the other hand, to avoid this error, you may increase the amount of heap space available to the JVM by modifying the -Xmx parameter in the Java command line. However, it is not recommended to allocate a large amount of memory to the heap space, as it can cause other performance issues and may not necessarily solve the problem.
- Actually, there’s a different problem.
<a href='https://test-import-0:443'>ramesh1234_230112_123641_4386<a/>
The error in the HTML body is that the closing tag of the anchor element is not properly formatted. It is missing the forward-slash character “/” before the closing angle bracket “>”.
The correct HTML code for the anchor element should be:
<a href='https://test-import-0:443'>ramesh1234_230112_123641_4386</a>
HTML parser Aspose.Email can not recognize the closing tag <a/>
, thus, throws an exception.
Thanks for the reply @margarita.samodurova
The attached email having incorrectly formatted html was able to render properly on Outlook but Aspose was unable to load this email.
So could you please confirm that Aspose would be unable to load such emails not having properly formatted html content or is there any possible solution or alternative approach to it.
@SudhanshuPanwar,
Ok, we’ll fix the MapiMessage loading in Aspose.Email to eliminate cases of exceptions with corrupted HTMLs.
However, please, note that Aspose.Email won’t necessarily copy Outlook’s behavior, as it uses different methods of message parsing.
@SudhanshuPanwar
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): EMAILNET-41034
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.