bbottema / outlook-message-parser

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

IllegalArgumentException when using EmailConverter.outlookMsgToEmail() #65

Closed manologhernandez closed 9 months ago

manologhernandez commented 1 year ago

Hello,

I have found that outlookMsgToEmail is failing for a specific file. The file is zipped here: MSG File.zip

The logs show the following exception is thrown:

java.lang.IllegalArgumentException: emailAddressList is required at org.simplejavamail.internal.util.Preconditions.verifyNonnullOrEmpty(Preconditions.java:49) ~[core-module-7.8.1.jar:?] at org.simplejavamail.internal.util.Preconditions.checkNonEmptyArgument(Preconditions.java:30) ~[core-module-7.8.1.jar:?] at org.simplejavamail.internal.util.MiscUtil.extractEmailAddresses(MiscUtil.java:171) ~[core-module-7.8.1.jar:?] at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.withRecipients(EmailPopulatingBuilderImpl.java:1436) ~[simple-java-mail-7.8.1.jar:?] at org.simplejavamail.email.internal.EmailPopulatingBuilderImpl.to(EmailPopulatingBuilderImpl.java:849) ~[simple-java-mail-7.8.1.jar:?] at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.copyReceiversFromOutlookMessage(OutlookEmailConverter.java:172) ~[outlook-module-7.8.1.jar:?] at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:112) ~[outlook-module-7.8.1.jar:?] at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.outlookMsgToEmailBuilder(OutlookEmailConverter.java:89) ~[outlook-module-7.8.1.jar:?] at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:243) ~[simple-java-mail-7.8.1.jar:?] at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:225) ~[simple-java-mail-7.8.1.jar:?] at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:217) ~[simple-java-mail-7.8.1.jar:?]

I understand it has something to do with the "To", "From", and "CC" email list being null/empty. But this happens when the user has left the exchange directory. The MSG saved will contain no email address but only the display name. The file is not corrupted, as Outlook can still open and view the file.

Would it be possible to support having a null emailList? This is so that parsing and conversion will not fail for this certain circumstance. Thank you

piu130 commented 9 months ago

We have the same problem when there is a list of correct recipients but one of them does not have an email. image

I don't know if it's feasible but it would be nice to separate the read model (parsing) from the write model (sending) and remove most of the validations from the read model.

bbottema commented 9 months ago

I can't reproduce the original exception with the given zip. I do get an "org.simplejavamail.jakarta.mail.internet.AddressException: Local address contains control or whitespace", but it is only logged as a DEBUG message. Please confirm the version you used for this and also please try with the latest version. Closing until I have more to go on.