Repository navigation
Description
Summary
Inline images are not detected when parsing .msg files generated by New Outlook (and possibly Outlook Online).
After investigating the issue, it appears that the exported MSG:
- Does not contain an RTF body.
- Contains attachment Content-ID properties with trailing NUL (
\u0000) characters. - Relies on HTML
cid:references for inline image detection. - Fails to match attachments to the HTML because the Content-ID value contains the trailing NUL while the HTML reference does not.
As a result, inline images are treated as normal attachments instead of embedded images.
Environment
- Simple Java Mail: 9.1.0
- Source message:
.msgexported/downloaded from New Outlook / Outlook Online
Potential fixes
Based on my investigation of the attached test.msg, I believe the following changes would resolve the issue.
1. Sanitize string values in OutlookMessageProperty
It appears that some string-based properties contain a trailing NUL character (\u0000).
For example, attachment Content-ID values may be exposed as:
177438a0-381f-49ff-a81f-57404ccdb560\u0000
while the HTML contains:
cid:177438a0-381f-49ff-a81f-57404ccdb560As a result, fetchCIDMap() is unable to match the attachment to the corresponding HTML cid: reference.
It may be beneficial to normalize string values when creating or reading the properties, for example by trimming trailing NUL characters.
2. Use the full HTML body for CID matching
fetchCIDMap() currently performs CID matching against:
final String html = getConvertedBodyHTML();For the attached MSG generated by New Outlook, there is no RTF body and inline image detection appears to depend entirely on HTML-based CID resolution.
It may therefore be more reliable to also inspect the full getBodyHTML() when resolving inline images rather than relying solely on getConvertedBodyHTML().
This would provide a fallback for MSG files generated by New Outlook / Outlook Online that rely exclusively on HTML content.
Why I think these changes would help
The attached test.msg was created using New Outlook and contains:
- Subject:
test - Body: the text
Hello Worldfollowed by an inline image - Attachment:
test.pdf
When parsed, the PDF attachment is correctly detected, but the inline image is not recognized as an embedded image and instead appears as a regular attachment.
My suspicion is that this is caused by a combination of:
- Missing RTF content.
- CID matching based only on
getConvertedBodyHTML(). - Content-ID values containing trailing NUL characters.
Activity
bbottema commentedon Aug 4, 2026
Fixed upstream in bbottema/outlook-message-parser#90 and released in
org.simplejavamail:outlook-message-parser:1.16.2.The parser now:
test.pdfremains a true attachment.The existing suite missed this because its CID-positive fixtures were all RTF-backed and had clean metadata; it had neither a native-HTML-only New Outlook fixture nor a unit contract for MAPI string terminators.
Simple Java Mail users can override the parser dependency to 1.16.2 immediately; the next Simple Java Mail dependency update can consume this patch normally. Closing as resolved upstream.
bbottema commentedon Aug 4, 2026
Thanks for reporting! Will release soon.
rogersteblerbsi commentedon Aug 4, 2026
Wow, that was fast 😄 Thanks for the fix! I've tested it and can confirm it's working correctly now.
bbottema commentedon Aug 4, 2026
Available now in Simple Java Mail 9.1.3 and on Maven Central. This release consumes
outlook-message-parser1.16.2, including the reported New Outlook.msgregression fixture and fix.bbottema commentedon Aug 4, 2026
By the power of Greysk.... no wait. By our powers combined, Captain Pl... no also not. Hold on. By the powers of my coding agents combined, I have the pow.... meh
Anyway, yep. Codex with Remote is pretty awesome as a fast response service.