Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

Access Attached Message (Embedded Email)

How to access an email embedded within another email (i.e. an attached message).

Chilkat Rust Downloads

Rust

let email = chilkat::Email::new();

// Load an email from a .eml
if email.load_eml("embeddedEmail.eml").is_err() {
    println!("{}", email.last_error_text());
    return;
}

// Display how many attached emails are embedded within
// this one:
let num_attached = email.num_attached_messages();
println!("numAttached = {}", num_attached);

// Get the 1st attached message.
let email2 = chilkat::Email::new();
if email.get_attached_email(0, &email2).is_ok() {

    // Display the subject, From, and a header field...
    println!("{}", email2.subject());
    println!("{}", email2.from());
    println!("{}", email2.get_header_field("X-SOMETHING").unwrap_or_default());
}