Skip to content

Allow zero data attachments so Outlook message conversions don't crash and burn #318

@LaurentFl

Description

@LaurentFl

I get an error when converting an Outlook msg received from a sender who sends email with an attachment which has no data:
java.lang.IllegalArgumentException: data is required at org.simplejavamail.internal.util.Preconditions.verifyNonnull(Preconditions.java:41) at org.simplejavamail.internal.util.Preconditions.checkNonEmptyArgument(Preconditions.java:30) at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withAttachment(EmailPopulatingBuilderImpl.java:1698) at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:117) at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.outlookMsgToEmailBuilder(OutlookEmailConverter.java:59) at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:194) at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:178)

Maybe it will be better if those attachments are ignored instead of throwing an Exception and block all the email conversion.
To fix this, we can check if attachment.getData() != null before calling builder.withAttachment() in OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:117)?
Or check if ((OutlookFileAttachment) attachment).getData() != null in OutlookMessage.fetchTrueAttachments() before adding it to fileAttachments ArrayList?

Maybe we need to keep this behavior to be RFC compliant?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions