# bbottema/outlook-message-parser architecture

> Architecture diagram of the GitHub repository bbottema/outlook-message-parser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bbottema/outlook-message-parser
- Repository: https://github.com/bbottema/outlook-message-parser

## Overview

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: [`src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java`](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java) (Parser), [`src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessage.java`](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessage.java) (OutlookMessage), [`src/test/java/org/simplejavamail/outlookmessageparser/OutlookMessageParserTest.java`](https://github.com/bbottema/outlook-message-parser/blob/master/src/test/java/org/simplejavamail/outlookmessageparser/OutlookMessageParserTest.java) (Parser tests), [`src/test/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageTest.java`](https://github.com/bbottema/outlook-message-parser/blob/master/src/test/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageTest.java) (Model tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_format["File format boundary"]
  node_msg_format[("MSG file<br/>compound doc")]
  node_poifs_layer["POIFS/OLE2<br/>file-format"]
end

subgraph group_group_parser["Parsing layer"]
  node_parser["Parser<br/>entrypoint"]
  node_prop_decode["Property decode<br/>property-mapping"]
  node_content_normalize["Content normalize<br/>content-flow"]
  node_attachment_flow["Attachment flow<br/>attachment-handling"]
  node_recipient_flow["Recipient parse<br/>address-normalization"]
  node_smime_flow["S/MIME parse<br/>security-metadata"]
  node_mime_hint["MIME infer<br/>type-detection<br/>[mimetypes.txt]"]
end

subgraph group_group_model["Domain model"]
  node_message_model["OutlookMessage<br/>aggregate root"]
  node_recipient_model(("OutlookRecipient<br/>recipient model"))
  node_attachment_model["OutlookAttachment<br/>attachment model"]
  node_file_attachment_model["File attachment<br/>attachment model"]
  node_msg_attachment_model["MSG attachment<br/>attachment model"]
  node_smime_model(("OutlookSmime<br/>security model<br/>[OutlookSmime.java]"))
  node_property_model["Property model<br/>metadata model"]
end

subgraph group_group_mime["Mail/MIME utilities"]
  node_mail_utils["Jakarta mail<br/>mail helpers"]
  node_encoder_utils["Encoding utils<br/>mime-encoding"]
end

subgraph group_group_test["Regression tests"]
  node_parser_tests["Parser tests<br/>behavior tests"]
  node_model_tests["Model tests<br/>unit tests"]
  node_samples[("MSG samples<br/>test corpus")]
end

node_msg_format -->|"stored in"| node_poifs_layer
node_poifs_layer -->|"read by"| node_parser
node_parser -->|"extracts"| node_prop_decode
node_parser -->|"builds bodies"| node_content_normalize
node_parser -->|"collects"| node_attachment_flow
node_parser -->|"normalizes"| node_recipient_flow
node_parser -->|"detects"| node_smime_flow
node_attachment_flow -->|"infers types"| node_mime_hint
node_recipient_flow -->|"parses addresses"| node_mail_utils
node_content_normalize -->|"decodes text"| node_mail_utils
node_content_normalize -->|"handles encodings"| node_encoder_utils
node_prop_decode -->|"maps to"| node_property_model
node_attachment_flow -->|"creates"| node_attachment_model
node_attachment_flow -->|"creates"| node_file_attachment_model
node_attachment_flow -->|"creates"| node_msg_attachment_model
node_smime_flow -->|"fills"| node_smime_model
node_recipient_flow -->|"creates"| node_recipient_model
node_content_normalize -->|"assembles"| node_message_model
node_prop_decode -->|"assembles"| node_message_model
node_attachment_flow -->|"assembles"| node_message_model
node_recipient_flow -->|"assembles"| node_message_model
node_smime_flow -->|"assembles"| node_message_model
node_parser_tests -->|"verifies"| node_parser
node_parser_tests -->|"uses"| node_samples
node_model_tests -->|"verifies"| node_message_model
node_model_tests -->|"verifies"| node_file_attachment_model

click node_parser "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java"
click node_mime_hint "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/resources/mimetypes.txt"
click node_message_model "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessage.java"
click node_recipient_model "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookRecipient.java"
click node_attachment_model "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookAttachment.java"
click node_file_attachment_model "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookFileAttachment.java"
click node_msg_attachment_model "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMsgAttachment.java"
click node_smime_model "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookSmime.java"
click node_property_model "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageProperty.java"
click node_mail_utils "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/jakarta/mail/internet/InternetAddress.java"
click node_encoder_utils "https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/com/sun/mail/util/BASE64EncoderStream.java"
click node_parser_tests "https://github.com/bbottema/outlook-message-parser/blob/master/src/test/java/org/simplejavamail/outlookmessageparser/OutlookMessageParserTest.java"
click node_model_tests "https://github.com/bbottema/outlook-message-parser/blob/master/src/test/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageTest.java"
click node_samples "https://github.com/bbottema/outlook-message-parser/tree/master/src/test/resources/test-messages"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_msg_format,node_poifs_layer toneBlue
class node_parser,node_prop_decode,node_content_normalize,node_attachment_flow,node_recipient_flow,node_smime_flow,node_mime_hint toneAmber
class node_message_model,node_recipient_model,node_attachment_model,node_file_attachment_model,node_msg_attachment_model,node_smime_model,node_property_model toneMint
class node_mail_utils,node_encoder_utils toneRose
class node_parser_tests,node_model_tests,node_samples toneIndigo
```

## Components

### File format boundary

OLE2/POIFS compound document structure used by .msg files

- **MSG file**: compound doc · Inbound Outlook .msg container
- **POIFS/OLE2**: file-format · Compound-document access layer the parser reads through

### Parsing layer

Reads Outlook internals and normalizes message content

- [Parser](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java): entrypoint · Main orchestration entry point for parsing .msg files · `src/main/java/org/simplejavamail/outlookmessageparser/OutlookMessageParser.java`
- **Property decode**: property-mapping · Extracts Outlook properties and field metadata
- **Content normalize**: content-flow · Builds text, HTML, and RTF-derived message bodies
- **Attachment flow**: attachment-handling · Handles file attachments, embedded images, and nested messages
- **Recipient parse**: address-normalization · Parses TO/CC/BCC and X500-style addresses
- **S/MIME parse**: security-metadata · Extracts signed/encrypted message metadata
- [MIME infer](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/resources/mimetypes.txt): type-detection · Infers attachment content types from metadata and resources · `src/main/resources/mimetypes.txt`

### Domain model

Library-friendly email objects produced by the parser

- [OutlookMessage](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessage.java): aggregate root · Primary parsed message object · `src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessage.java`
- [OutlookRecipient](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookRecipient.java): recipient model · Normalized message recipient · `src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookRecipient.java`
- [OutlookAttachment](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookAttachment.java): attachment model · Base attachment abstraction · `src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookAttachment.java`
- [File attachment](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookFileAttachment.java): attachment model · Physical file attachment representation · `src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookFileAttachment.java`
- [MSG attachment](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMsgAttachment.java): attachment model · Nested .msg attachment representation · `src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMsgAttachment.java`
- [OutlookSmime](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookSmime.java): security model · S/MIME metadata held in the domain model · `src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookSmime.java`
- [Property model](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageProperty.java): metadata 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](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/jakarta/mail/internet/InternetAddress.java): mail helpers · Bundled address, header, and MIME parsing utilities · `src/main/java/org/simplejavamail/jakarta/mail/internet/InternetAddress.java`
- [Encoding utils](https://github.com/bbottema/outlook-message-parser/blob/master/src/main/java/org/simplejavamail/com/sun/mail/util/BASE64EncoderStream.java): mime-encoding · 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](https://github.com/bbottema/outlook-message-parser/blob/master/src/test/java/org/simplejavamail/outlookmessageparser/OutlookMessageParserTest.java): behavior tests · End-to-end parsing tests against real .msg samples · `src/test/java/org/simplejavamail/outlookmessageparser/OutlookMessageParserTest.java`
- [Model tests](https://github.com/bbottema/outlook-message-parser/blob/master/src/test/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageTest.java): unit tests · Behavior checks for output model objects · `src/test/java/org/simplejavamail/outlookmessageparser/model/OutlookMessageTest.java`
- [MSG samples](https://github.com/bbottema/outlook-message-parser/tree/master/src/test/resources/test-messages): test corpus · Real-world Outlook messages covering edge cases · `src/test/resources/test-messages`

## Connections

- 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
