You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide control over synthetic HTML fallback when converting Outlook (.msg) plain-text emails #979
Thank you again for your hard work on this fantastic E-Mail library.
Context & Current Behavior
When converting an Outlook .msg file via EmailConverter.outlookMsgToEmail(...), SJM checks whether native HTML is available (outlookMessage.getBodyHTML()). If absent, it automatically falls back to converted RTF.
In Outlook, even pure plain-text emails are internally wrapped in RTF (indicated by \fromtext in the RTF body). When outlookMessage.getConvertedBodyHTML() runs on such an email, it produces synthetic HTML.
While this opinionated fallback is very helpful for standard rendering, it causes issues in downstream processing pipelines (e.g. when HTML sanitizers or strict safety filters strip inline styles, turning plain-text emails into an unreadable single line of text).
Problem
Currently, callers cannot opt out of this synthetic HTML generation, nor can they determine whether the original message was originally plain text without parsing the entire .msg file a second time with OutlookMessageParser (which incurs significant memory and CPU overhead for large messages with attachments).
OutlookEmailConversionResult provides OutlookMessageData, but it does not expose the raw RTF body or an indicator of whether the source message was plain text.
Proposed Solutions / Discussion
Option 1: Expose isPlainText() or raw RTF in OutlookMessageData
Add a method boolean isPlainText() (e.g. checking if bodyRTF is absent or contains the "\fromtext" control word) to OutlookMessageData.
Benefit: Callers can inspect result.getOutlookMessageData().isPlainText() and call builder.clearHTMLText() if desired, keeping backward compatibility 100% intact.
Option 2: Configuration option via SimpleJavaMailConfig
Introduce a configuration property (e.g. simplejavamail.outlook.fallback_to_converted_html=true|false or a parameter in EmailConverter) to allow skipping the synthetic HTML conversion when no native HTML body exists.
Thanks for explaining the use case. For 9.3.10, I plan to add getBodyHTML() and getBodyRTF() to OutlookMessageData, so you can inspect the native MSG bodies from the same conversion. The HTML value will exclude the RTF fallback; the RTF value will be the reader's decompressed/decoded text. The existing best-effort HTML fallback stays as it is.
That gives your application the source information for its own policy, followed by result.getEmailBuilder().clearHTMLText() when plain-text output is appropriate. Missing native HTML alone won't mean the message was originally plain text: RTF can also contain original HTML or rich text. These values describe the native MSG, so they can differ from content selected later through S/MIME processing.
For 10.0.0, a fuller inspection API is planned, along these lines:
// Planned for 10.0.0; not an available 9.x API.email.getInspection().getHTMLText();
The idea is to describe the origin, derivation and protection of the HTML actually returned by that Email, including content selected from protected or nested messages. Those result types are still under design.
Thanks a lot for the quick feedback and for including this in 9.3.10!
Exposing getBodyHTML() and getBodyRTF() on OutlookMessageData solves our issue completely. It gives us all the info we need to apply our policy via result.getEmailBuilder().clearHTMLText() without having to parse the file twice.
Also, thanks for the helpful clarification regarding rich-text RTF vs. plain-text RTF.
Available in 9.3.10. nativeHtml contains the native MSG HTML without the RTF fallback, and rtf contains the reader's decompressed and decoded RTF text. A missing or uncaptured value is null; an explicitly empty value stays empty. Existing HTML conversion and fallback behavior stay as they are.
For an ordinary unprotected MSG, once your application has selected plain-text output, you can use result.getEmailBuilder().clearHTMLText().buildEmail().
Activity
bbottema commentedon Nov 9, 2026
Thanks for explaining the use case. For 9.3.10, I plan to add
getBodyHTML()andgetBodyRTF()toOutlookMessageData, so you can inspect the native MSG bodies from the same conversion. The HTML value will exclude the RTF fallback; the RTF value will be the reader's decompressed/decoded text. The existing best-effort HTML fallback stays as it is.That gives your application the source information for its own policy, followed by
result.getEmailBuilder().clearHTMLText()when plain-text output is appropriate. Missing native HTML alone won't mean the message was originally plain text: RTF can also contain original HTML or rich text. These values describe the native MSG, so they can differ from content selected later through S/MIME processing.For 10.0.0, a fuller inspection API is planned, along these lines:
The idea is to describe the origin, derivation and protection of the HTML actually returned by that Email, including content selected from protected or nested messages. Those result types are still under design.
clepet commentedon Nov 9, 2026
Thanks a lot for the quick feedback and for including this in 9.3.10!
Exposing
getBodyHTML()andgetBodyRTF()onOutlookMessageDatasolves our issue completely. It gives us all the info we need to apply our policy viaresult.getEmailBuilder().clearHTMLText()without having to parse the file twice.Also, thanks for the helpful clarification regarding rich-text RTF vs. plain-text RTF.
Looking forward to the 9.3.10 release!
docs(outlook): explain native MSG source bodies (#979)
feat(outlook): expose native MSG body data (#979)
bbottema commentedon Nov 9, 2026
Available in 9.3.10.
nativeHtmlcontains the native MSG HTML without the RTF fallback, andrtfcontains the reader's decompressed and decoded RTF text. A missing or uncaptured value isnull; an explicitly empty value stays empty. Existing HTML conversion and fallback behavior stay as they are.For an ordinary unprotected MSG, once your application has selected plain-text output, you can use
result.getEmailBuilder().clearHTMLText().buildEmail().The source-body addition and usage guide describe the 9.x API.