bbottema / outlook-message-parser

A Java parser for Outlook messages (.msg files)
76 stars 35 forks source link

Enhancement: ignore attachment with missing content #69

Closed piu130 closed 9 months ago

piu130 commented 9 months ago

When parsing an msg with an empty embedded image, the parser throws IllegalArgumentException: data is required.

We have several of those errors and the files are mostly called com_samsung_android_email_attachmentprovider_.... Those images are in the signature. Maybe the signature references images on the senders main device which are not available on the secondary device?

Anyway, it would be good if the parser would not fail for empty embedded files.

Sample: image

Stacktrace (v 8.3.3):

java.lang.IllegalArgumentException: data is required

    at org.simplejavamail.internal.util.Preconditions.verifyNonnullOrEmpty(Preconditions.java:49)
    at org.simplejavamail.internal.util.Preconditions.checkNonEmptyArgument(Preconditions.java:30)
    at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withEmbeddedImage(EmailPopulatingBuilderImpl.java:1669)
    at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:122)
    at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.outlookMsgToEmailBuilder(OutlookEmailConverter.java:89)
    at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:250)
    at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:228)
    at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:220)
        ...
bbottema commented 9 months ago

This bug is reported in the wrong project (it should be https://github.com/bbottema/simple-java-mail/), but I'll have a look anyway.

bbottema commented 9 months ago

The problem is not missing images one device or another, the problem is the email is malformed. It contains an attachment with a cid.key (used for embedded images) for which the image data is missing (not empty, but missing). I'll see what I can do about making the parser more tolerant.

bbottema commented 9 months ago

I've made the parser ignore attachments with missing data and released outlook-message-parser:1.11.0.

In your project where you use Simple Java Mail, can you please include the following and see if it fixes your problem?

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.simplejavamail</groupId>
                <artifactId>outlook-message-parser</artifactId>
                <version>1.11.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

If this fixes your problem, I'll release a new version of Simple Java Mail as well.

piu130 commented 9 months ago

It works with version 1.11.0. As always, thank you very much for the fast support and the detailed explanation :)

bbottema commented 9 months ago

I'm going to revert this change. It breaks the fix for https://github.com/bbottema/simple-java-mail/issues/318. I'll have to think of something else. Sorry, I should've checked this first myself.

bbottema commented 9 months ago

Released 1.11.1, which fixes it as well but doesn't cause issues for normal attachments.

bbottema commented 9 months ago

simple-java-mail:8.3.4 released with this fix.