Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointer when parsing Outlook Message with nested empty Outlook message #326

Closed
Faelean opened this issue Jun 28, 2021 · 5 comments
Closed

Comments

@Faelean
Copy link

Faelean commented Jun 28, 2021

Hi,
when I run the following code I get a NullPointer for some msg files. Parsing the file with the OutlookMessageParser and then calling the getDate() method doesn't produce the error so the problem appears to be related to converting the OutlookMessage to an Email.
This doesn't affect the majority of mails and I haven't figured out what's special about the example mails I have.
I can't publish these mails here, but if you want I can send them to you.

	public static void main(String[] args) throws IOException {
		String msgFileName = ".\\files\\example.msg";
		
		try (FileInputStream fileInputStream = new FileInputStream(msgFileName)) {

			Email email = EmailConverter.outlookMsgToEmail(fileInputStream);
			
			//OutlookMessageParser outlookMessageParser = new OutlookMessageParser();
			//OutlookMessage outlookMessage = outlookMessageParser.parseMsg(fileInputStream);
			//outlookMessage.getDate();
		}
	}
Exception in thread "main" java.lang.NullPointerException
	at org.simplejavamail.outlookmessageparser.model.OutlookMessage.getDate(OutlookMessage.java:856)
	at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:102)
	at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.buildEmailFromOutlookMessage(OutlookEmailConverter.java:123)
	at org.simplejavamail.internal.outlooksupport.converter.OutlookEmailConverter.outlookMsgToEmailBuilder(OutlookEmailConverter.java:85)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:230)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:212)
	at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:204)
@bbottema
Copy link
Owner

I can understand the exception bug when date is null somehow, but I cannot explain the difference between converting it with EmailConverter vs OutlookMessageParser. I would actually like to reproduce it with the debugger, so if you could send your problem email, I would really appreciate it.

@bbottema
Copy link
Owner

It turns out that outlook-message-parser identifies a nested Outlook message attached, which is completely empty (which is invalid). I'm not sure why it finds a nested Outlook attachment, but I need some criteria by which I can ignore such an attachment.

image

@bbottema
Copy link
Owner

This use case is resolved if I reject nested Outlook messages when their ID is empty, but I have no idea if this is always the case. At least all the existing junit tests still pass, including the ones with nested message attachments, but I would like to have more confidence in this solution.

@bbottema
Copy link
Owner

bbottema commented Jul 3, 2021

I fixed the issue which will be in release 7.0.0. It might take some time for this fix to go public because of that. In the meantime, you can fix it by forcing the outlook-message-parser dependency to version >= 1.7.12.

<dependencyManagement>
  <dependencies>
    <dependency><!-- fixes #326 (workaround until SJM 7.0.0 is released) -->
      <groupId>org.simplejavamail</groupId>
      <artifactId>outlook-message-parser</artifactId>
      <version>1.7.12</version>
    </dependency>
 </dependencies>
</dependencyManagement>

@bbottema bbottema closed this as completed Jul 3, 2021
@bbottema bbottema added this to the 7.0.0 milestone Jul 3, 2021
@bbottema bbottema changed the title NullPointer when parsing Outlook Message NullPointer when parsing Outlook Message with nested empty Outlook message Jan 2, 2022
@bbottema
Copy link
Owner

bbottema commented Jan 2, 2022

7.0.0 just released with the fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants