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

Free Support Forum - aspose.com

TNEF mail causes excessive cpu and memory usage

We have found 3 emails in tnef format that cause Aspose Email to use excessive quantity of cpu and memory - suggesting a loop of some sort.
The mails (.eml files) display in Outlook - though even here they seem to take time to load/display.
MailsCauseAsposeHighCPU.zip (490.9 KB)


We have logged this problem in our issue tracking system as EMAILNET-40588. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

I am just trying the latest release (aspose-email-22.4-jdk16.jar) and it is still taking several minutes to load these .tnef containing files. Is there some configuration that I need to apply before trying to load such files?
If not, why was this case closed? Is it because it cannot be fixed? Would it help if I provided the logical breakdown of the tnef content?


Your issue was logged for Aspose.Email for .NET. We have logged new issue as EMAILJAVA-35054 in our issue tracking system for Aspose.Email for Java. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

I might have spoken too soon! It is possible that my PC had cached the previous aspose .jar. After retrying in different ways, it now processes these files very quickly - down from over 10 minutes to less than 4 seconds!

Thank you,


Perhaps, product team fixed the same issue in Aspose.Email for Java. However, it is not mentioned in release notes. Please clear the cache, remove all old JAR files and install latest version of Aspose.Email for Java 22.4. Please confirm if your issue is resolved. We will then close the EMAILJAVA-35054.

I have re-evaluated this case. I was wrong to assert that the fault was with the loading of the problem files. It was in some supplementary logic that I use to apply to ‘fix’ mails that had no plain text part. Here I check if the msg.body is empty or null (using ‘groovy’ logic)…

MailMessage msg = MailMessage.load(in);
if (!msg.body) {

However, I find that just referencing the msg.body property for these mails results in this very long delay and high cpu. (yet no such delay with hundreds of thousands of other files!)

I figured that the emails must have an HTML part - and interpreting this was the thing that was taking time. Yet all I was trying to determine is if the ‘body’ was empty. So have now changed the logic.

The old code looked like this:

                //fix 3 - if the body is empty then a tnef signature is left
                if (!msg.body && !msg.bodyHtml) {
                    //if ignored, the result is an empty email but with TNEF/binary content headers. 
                    msg.setBodyEncoding (Charset.forName('utf-8'))
                    if (verbose) {println "  NOTE: this email ${msgFile.name} has no body"}

And now I added check to see if there are multi-parts - and only if NOT to test the body content like this:

                if (msg.alternateViews.size() == 0 && !msg.bodyHtml && !msg.body) {

and the system is now quick.

So I apologise for misleading you. [Though it would be useful if I did not need to use this work-around fix when using Aspose]


Thanks for sharing the detail. We will inform you via this forum thread once your issue is resolved.