Skip to main content

Crate msg_parser

Crate msg_parser 

Source
Expand description

§msg_parser

A parser for Microsoft Outlook .msg files (OLE Compound Document format).

Extracts message metadata, body content, recipients, attachments, and transport headers from .msg files as specified in MS-OXMSG and MS-OXPROPS.

§Quick Start

use msg_parser::Outlook;

let outlook = Outlook::from_path("email.msg").unwrap();

// Use Display impl for a human-readable summary
println!("{}", outlook);

// Or access fields directly
println!("From: {}", outlook.sender);
println!("Subject: {}", outlook.subject);
println!("Date: {}", outlook.message_delivery_time);

for attach in &outlook.attachments {
    println!("Attachment: {}", attach);
}

§Parsing from different sources

use msg_parser::Outlook;

// From a file path
let outlook = Outlook::from_path("email.msg").unwrap();

// From a byte slice (accepts &[u8], Vec<u8>, or anything AsRef<[u8]>)
let bytes = std::fs::read("email.msg").unwrap();
let outlook = Outlook::from_slice(&bytes).unwrap();

// From any reader (file, stdin, network stream, etc.)
let file = std::fs::File::open("email.msg").unwrap();
let outlook = Outlook::from_reader(file).unwrap();

§Embedded messages

for attach in &outlook.attachments {
    if let Some(Ok(nested)) = attach.as_message() {
        println!("Embedded: {} from {}", nested.subject, nested.sender);
    }
}

§HTML from RTF fallback

let html = if !outlook.html.is_empty() {
    outlook.html.clone()
} else {
    outlook.html_from_rtf().unwrap_or_default()
};

Structs§

Attachment
A file attachment on the message.
Outlook
A parsed Outlook .msg email message.
Person
A person referenced in the message (sender, recipient, CC, or BCC).
TransportHeaders
SMTP transport headers from the message envelope.

Enums§

DataTypeError
Error type for property value decoding failures.
Error
Top-level error type returned by Outlook parsing methods.