microsoft / microsoft/markitdown
Outlook converter reads incorrect fields from Outlook 365 (April 2025) files, misses HTML content - Fix included
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 186k
- Forks
- 13.7k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 49
Description
A MSG file from Outlook 356 is not processed correctly. Fix attached (not production ready, please see if e.g. want to use Markdownify library?).
TO REPRODUCE
I'm passing a msg file saved from the browser version of Outlook 365. Unfortunately I can't share the file as I got it from another person, and I don't have direct access to O365 myself, but what failed was:
- It took from field from a field which has organizational info, not email address (From field was something like "/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP..."
- It misses messages with HTML-only body; that is, ## Content is empty if the message is an html-only message
ELABORATION ON VERSIONS / TESTING
I'm not sure if the existing implementation works with some older/other MSG files? However, attached a version of the implementation which works with messages exported from Outlook O365 browser version as of today. Unfortunately I don't have access to Outlook myself, so I'm unable to verify if this new version works with other versions, or test this thoroughly.
THE FIX
Attached an Outlook converter source code file with the following changes:
- take From field correctly
- in case the text-only body is missing, try to find the html body
-- it seems that at least with my python3.12, decode with UTF-16 succeeds without throwing even if the payload is actually iso-8859-1 (just output is then malformed), so we're attempting several different decodings, and see if the output looks like html
-- finally, also run the html output through another library, markdownify, to turn HTML into markdown (I did not find html converter within markitdown, so thus using a 3rd party library)
While creating the fix, I found this web page helpful in finding out the correct streams; I did check also Microsoft's own documentation that I found, but it did not match what I had in the MSG file. :)
https://www.devhut.net/retrieving-email-header-information-in-outlook-using-vba-part-2/
ATTACHED FIX
_outlook_msg_converter_py.txt
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the current Outlook converter with the attached _outlook_msg_converter_py.txt implementation, focusing on the From-field streams and fallback handling for HTML-only bodies. Check how the converter currently decodes and renders MSG content; done means Outlook 365 browser exports provide the email address and non-empty Markdown content when no text body exists, while preserving older MSG behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100