How bbottema/outlook-message-parser works
1. This repository is a standalone Java library, not an application. Its purpose is to parse Microsoft Outlook .msg files and expose the contents as Java model objects.
2. The core entry point is OutlookMessageParser in org.simplejavamail.outlookmessageparser. It orchestrates reading a message file, extracting Outlook properties, and building an OutlookMessage domain object.
3. The parser sits on top of the OLE2/POIFS structure used by .msg files, as noted in the README. That file-format layer is the main external boundary: the library interprets Outlook’s compound document format and converts it into higher-level email data.
4. The main output model lives in org.simplejavamail.outlookmessageparser.model. Key objects include:
- OutlookMessage as the aggregate root
- OutlookRecipient for TO/CC/BCC-style people
- OutlookAttachment plus OutlookFileAttachment and OutlookMsgAttachment for attachments and nested .msg attachments
- OutlookSmime for S/MIME metadata
- OutlookMessageProperty and OutlookFieldInformation for low-level property mapping
5. The package structure shows a clear two-layer design: a parsing layer that understands Outlook internals, and a model layer that represents the extracted email in a library-friendly form. This is the main architectural boundary to diagram.
6. The repository also bundles a subset of mail/MIME utility classes under org.simplejavamail.jakarta.mail and org.simplejavamail.com.sun.mail.util. These appear to provide address parsing, header parsing, MIME encoding/decoding, logging, and charset handling without depending on a full external mail implementation at runtime.
7. Resource-driven MIME detection is part of the architecture. src/main/resources/mimetypes.txt is used to infer attachment content types, especially for incomplete attachments or when Outlook metadata is missing.
8. The parser handles several email-content branches that matter architecturally:
- plain text and HTML bodies
- RTF-derived content conversion to HTML
- attachments, including embedded images and nested messages
- recipient/address normalization, including X500-style addresses
- S/MIME metadata extraction for signed/encrypted messages
9. Test data is a major part of the repository design. src/test/resources/test-messages contains many real .msg samples covering edge cases such as multilingual content, malformed headers, drafts, forwarded mail, embedded images, nested messages, and S/MIME. This indicates the parser is heavily regression-tested against real-world Outlook files rather than synthetic fixtures only.
10. The test suite is organized around parser behavior and model correctness:
- OutlookMessageParserTest and HighoverEmailsTest validate end-to-end parsing
- model tests such as OutlookMessageTest and OutlookFileAttachmentTest verify object-level behavior
- TestUtils likely centralizes sample-file loading and assertions
11. The repo is packaged as a Maven library (pom.xml) and is built/tested in CI via CircleCI and Travis configuration files. Release-related docs and scripts indicate the project is published to Maven Central, so the artifact boundary is the library JAR rather than a service deployment.
12. A good architecture diagram should show one inbound flow: .msg file input -> POIFS/Outlook property decoding -> parser/normalization logic -> domain model output. Side branches should show MIME/header utilities, attachment/type inference, and optional S/MIME/embedded-message handling feeding into the same final OutlookMessage graph.
Main entry points: OutlookMessageParser.java Parser · OutlookMessage.java OutlookMessage · OutlookMessageParserTest.java Parser tests · OutlookMessageTest.java Model tests
Components 21
File format boundary
OLE2/POIFS compound document structure used by .msg files
- MSG file · Inbound Outlook .msg container
- POIFS/OLE2 · Compound-document access layer the parser reads through
Parsing layer
Reads Outlook internals and normalizes message content
- Parser · Main orchestration entry point for parsing .msg files
src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java - Property decode · Extracts Outlook properties and field metadata
- Content normalize · Builds text, HTML, and RTF-derived message bodies
- Attachment flow · Handles file attachments, embedded images, and nested messages
- Recipient parse · Parses TO/CC/BCC and X500-style addresses
- S/MIME parse · Extracts signed/encrypted message metadata
- MIME infer · Infers attachment content types from metadata and resources
src/main/resources/mimetypes.txt
Domain model
Library-friendly email objects produced by the parser
- OutlookMessage · Primary parsed message object
src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessage.java - OutlookRecipient · Normalized message recipient
src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookRecipient.java - OutlookAttachment · Base attachment abstraction
src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookAttachment.java - File attachment · Physical file attachment representation
src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookFileAttachment.java - MSG attachment · Nested .msg attachment representation
src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMsgAttachment.java - OutlookSmime · S/MIME metadata held in the domain model
src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookSmime.java - Property model · Low-level Outlook property and field mapping objects
src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageProperty.java
Mail/MIME utilities
Bundled helpers for addresses, headers, encoding, and logging
- Jakarta mail · Bundled address, header, and MIME parsing utilities
src/main/java/org/simplejavamail/jakarta/mail/internet/InternetAddress.java - Encoding utils · Base64, quoted-printable, and MIME helper streams
src/main/java/org/simplejavamail/com/sun/mail/util/BASE64EncoderStream.java
Regression tests
Behavior tests driven by real Outlook sample messages
- Parser tests · End-to-end parsing tests against real .msg samples
src/test/java/org/simplejavamail/outlookmessageparser/OutlookMessageParserTest.java - Model tests · Behavior checks for output model objects
src/test/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageTest.java - MSG samples · Real-world Outlook messages covering edge cases
src/test/resources/test-messages
Connections 26
- MSG file → POIFS/OLE2: stored in · The .msg compound document is accessed through OLE2/POIFS structure
- POIFS/OLE2 → Parser: read by · Parser consumes the file-format layer
- Parser → Property decode: extracts · Reads Outlook properties and field metadata
- Parser → Content normalize: builds bodies · Creates plain text, HTML, and RTF-derived content
- Parser → Attachment flow: collects · Processes attachments and nested messages
- Parser → Recipient parse: normalizes · Converts Outlook recipient data to mail-style addresses
- Parser → S/MIME parse: detects · Extracts S/MIME message metadata when present
- Attachment flow → MIME infer: infers types · Uses resource-backed MIME detection when Outlook metadata is incomplete
- Recipient parse → Jakarta mail: parses addresses · Leverages bundled mail/header utilities
- Content normalize → Jakarta mail: decodes text · Uses MIME/header helpers for decoding and normalization
- Content normalize → Encoding utils: handles encodings · Supports MIME transfer encodings and character handling
- Property decode → Property model: maps to · Creates property and field information objects
- Attachment flow → OutlookAttachment: creates · Base attachment abstraction in the domain model
- Attachment flow → File attachment: creates · Represents file-backed attachments
- Attachment flow → MSG attachment: creates · Represents nested Outlook message attachments
- S/MIME parse → OutlookSmime: fills · Stores S/MIME metadata in the model
- Recipient parse → OutlookRecipient: creates · Produces normalized recipient objects
- Content normalize → OutlookMessage: assembles · Contributes body content to the aggregate message
- Property decode → OutlookMessage: assembles · Populates the top-level message aggregate
- Attachment flow → OutlookMessage: assembles · Attaches files and embedded messages to the aggregate
- Recipient parse → OutlookMessage: assembles · Adds recipient lists to the message aggregate
- S/MIME parse → OutlookMessage: assembles · Adds security metadata to the parsed message
- Parser tests → Parser: verifies · End-to-end parser behavior
- Parser tests → MSG samples: uses · Exercises parser against real sample messages
- Model tests → OutlookMessage: verifies · Checks model object behavior
- Model tests → File attachment: verifies · Checks attachment model behavior