-
Notifications
You must be signed in to change notification settings - Fork 11
Add support for inline attachments in HTML mails #119
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
base: master
Are you sure you want to change the base?
Conversation
@Tangresh |
Sure! The Content-ID is the identifier by which the images can be referenced and is set as |
@Tangresh Can you please rebase on master to fix conflicts ? 🙏 |
5ef6bc7
to
59d426a
Compare
@ctabin Done Edit: That was sloppy of me, I'll have to fix that commit again. |
59d426a
to
3d2caab
Compare
I have also tested my application with your updated master branch, looks like everything is still working. |
@Tangresh Thank you very much ! Yes I plan to integrate your PR and I'll do a new release right after. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tangresh I left a few comments :-)
|
||
final List<OutlookMessageAttachment> regularAttachments = getAttachments().stream() | ||
.filter(att -> att.getContentId() == null) | ||
.collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use JDK21.
.collect(Collectors.toList()); | |
.toList(); |
|
||
final List<OutlookMessageAttachment> inlineAttachments = getAttachments().stream() | ||
.filter(att -> att.getContentId() != null) | ||
.collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.collect(Collectors.toList()); | |
.toList(); |
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
else { | |
} else { |
message.setReplyTo(Arrays.asList("reply1@jotlmsg.com", "reply2@jotlmsg.com")); | ||
message.setPlainTextBody("Hello,\n\nThis is a simple message.\n\n.Bye."); | ||
message.setHtmlBody("<html><body>Simple body</body></html>"); | ||
message.addRecipient(OutlookMessageRecipient.Type.TO, "cedric@jotlmsg.com", "Cédric"); | ||
final OutlookMessageAttachment inlineAttachment = new OutlookMessageAttachment("picture.png", "image/png", new ByteArrayInputStream(new byte[0])); | ||
inlineAttachment.setContentId("picture.png"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make a test without the plain text and with an html part actually using linking the png to show how it works ?
This PR adds support for inline attachment support in HTML emails.
I am not entirely happy with the API as it is, where the contentId property has to be set with a setter on the OutlookMessageAttachment and the contentId is the only thing distinguishing it from a regular attachment.
Maybe they should be saved in a Map in the OutlookMessage, because one does not want multiple inline attachments with the same contentId?