Outlook Email Message (.msg) parser
A parser for Microsoft Outlook .msg files (OLE Compound Document format).
Extracts message metadata, body content, recipients, attachments, and transport
headers as specified in [MS-OXMSG] and [MS-OXPROPS].
Usage
Add this to your Cargo.toml:
[]
= "0.3"
Quick Start
use Outlook;
Parsing from different sources
use Outlook;
// From a file path
let outlook = from_path.unwrap;
// From a byte slice
let bytes = read.unwrap;
let outlook = from_slice.unwrap;
// From any std::io::Read source (file, stdin, network, etc.)
let file = open.unwrap;
let outlook = from_reader.unwrap;
Saving attachments
let outlook = from_path.unwrap;
for attach in &outlook.attachments
Detecting embedded messages
Attachments with attach_method == 5 are nested .msg files (embedded
messages). You can identify them and handle them separately:
for attach in &outlook.attachments
Message metadata
let outlook = from_path.unwrap;
// Timestamps (ISO 8601 UTC, empty string if unavailable)
println!;
println!;
println!;
println!;
// Classification
println!; // e.g. "IPM.Note"
println!; // 0=Low, 1=Normal, 2=High
println!; // 0=Normal, 1=Personal, 2=Private, 3=Confidential
JSON output
let outlook = from_path.unwrap;
let json = outlook.to_json.unwrap;
println!;
Available fields
| Field | Type | Description |
|---|---|---|
headers |
TransportHeaders |
SMTP transport headers (raw + parsed fields) |
sender |
Person |
Sender name and email |
to |
Vec<Person> |
Primary recipients |
cc |
Vec<Person> |
Carbon-copy recipients |
bcc |
Vec<Person> |
Blind carbon-copy recipients |
subject |
String |
Subject line |
body |
String |
Plain-text body |
html |
String |
HTML body |
rtf_compressed |
String |
RTF body (hex-encoded) |
message_class |
String |
Message class (e.g. "IPM.Note") |
importance |
u32 |
0=Low, 1=Normal, 2=High |
sensitivity |
u32 |
0=Normal, 1=Personal, 2=Private, 3=Confidential |
client_submit_time |
String |
ISO 8601 UTC timestamp |
message_delivery_time |
String |
ISO 8601 UTC timestamp |
creation_time |
String |
ISO 8601 UTC timestamp |
last_modification_time |
String |
ISO 8601 UTC timestamp |
attachments |
Vec<Attachment> |
File attachments with metadata and raw bytes |
Requirements
- Rust edition 2024 (rustc 1.85+)
Running the example
# or with a specific file:
Running tests
Contributions
Feel free to open pull requests to contribute, enhance, or fix bugs.
License: MIT