From e5dbc130ce32df2126f80cd95d023fb104a74c3d Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Wed, 2 Jul 2025 09:03:24 +0800 Subject: [PATCH] docs: update basic example with sample output --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++------- examples/hello.rs | 45 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 79 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5cbf4dc..0dab167 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ A tiny Outlook Email Message (.msg) reader ======================================= -A tiny reader for .msg files. +A tiny reader for .msg files. Supports embedded messages. ### Usage Example @@ -10,13 +10,46 @@ use tiny_msg::Email; fn main() { let email = Email::from_path("sample/sample1.msg"); + // basic headers + println!("From: {:?}", email.from.unwrap()); + println!("To: {:?}", email.to); + println!("Cc: {:?}", email.cc); + println!("Subject: {}", email.subject.unwrap()); + println!(); + // email body + println!("Body starts with: {:?}", &email.body.unwrap()[..50]); + println!(); + // attachments + println!( + "Attachments: {:?}", + email + .attachments + .iter() + .map(|a| a.name.clone()) + .collect::>() + ); + println!(); + // embedded messages + println!( + "Embedded Messages: {:?}", + email + .embedded_messages + .iter() + .map(|m| m.subject.as_ref().unwrap()) + .collect::>() + ); + println!(); + // OUTPUT: + // From: ("spoj", "spoj@example.com") + // To: [("john", "john@example.com")] + // Cc: [("karen", "karen@example.com")] + // Subject: Weekend plan - dbg!(&email.from); - dbg!(&email.to); - dbg!(&email.cc); - dbg!(&email.sent_date); - dbg!(&email.subject); - dbg!(&email.body); + // Body starts with: ">() + ); + println!(); + // embedded messages + println!( + "Embedded Messages: {:?}", + email + .embedded_messages + .iter() + .map(|m| m.subject.as_ref().unwrap()) + .collect::>() + ); + println!(); + // OUTPUT: + // From: ("spoj", "spoj@example.com") + // To: [("john", "john@example.com")] + // Cc: [("karen", "karen@example.com")] + // Subject: Weekend plan - dbg!(&email.from); - dbg!(&email.to); - dbg!(&email.cc); - dbg!(&email.sent_date); - dbg!(&email.subject); - dbg!(&email.body); + // Body starts with: "