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

Attachments of nested Outlook messages (being attachments themselves) missing #314

Closed
bbottema opened this issue May 4, 2021 · 1 comment

Comments

@bbottema
Copy link
Owner

bbottema commented May 4, 2021

Originally reported under #298:

When reading nested outlook messages back from the attachment datasource (as attachments on an Email instance are datasources), attachments said outlook message are missing.

The reason for this is that reading nested Outlook messages as attachment of another Outlook msg is only possible by converting it to a Java structure first (using outlook-message-parser). This is a one-way conversion. Since the nested outlook message-as-an-attachment should be represented as attachment under an Email instance, it should be serialized to a datasource. Nested attachments then of this nested Outlook message are datasources themselves and cannot be serialized (javax.activation.DataSource is a JDK interface).

To solve this problem, a more comprehensive serialization solution is needed. Kryo should solve the problem nicely.

@bbottema bbottema added this to the 6.5.3 milestone May 4, 2021
@bbottema
Copy link
Owner Author

bbottema commented May 4, 2021

Released in 6.5.3 (@atmcq).

So the OutlookModule now has an extra dependency on Kryo, but nested attachments are now maintained when trying the read back nested outlook messages. I'm including a convenient SerializationUtil to keep your code clean:

public Email getNestedOutlookMessage(...yourOutlookMessageSource) {
	Email email = EmailConverter.outlookMsgToEmail(yourOutlookMessageSource);

	// now the nested Outlook message is converted to an Email and subsequently serialized:
	// email.getAttachments().get(0).getName() == "attachment 0 as nested Outlook message (converted).sjm"

	InputStream sjmInputstream = email.getAttachments().get(0).getDataSourceInputStream();
	Email nestedOutlookMessage = SerializationUtil.deserialize(sjmInputstream);
	
	return nestedOutlookMessage; // now with attachments, yay!
}

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

1 participant