Sample code for 30+ languages & platforms
Rust

Unpack HTML Email to Files

Unpacks an HTML email into an HTML file and related files (images and style sheets). The links within the HTML are updated to point to the files unpacked and saved to disk.

Chilkat Rust Downloads

Rust

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

if email.load_eml("qa_data/eml/happyHour.eml").is_err() {
    println!("{}", email.last_error_text());
    return;
}

// Is this an HTML email?
if email.has_html_body() {

    // Unpack the HTML to files.  The image and css URLs
    // in the HTML are modified to point to the files extracted to disk.
    let unpack_dir = "qa_output/emails".to_string();
    let parts_subdir = "images".to_string();
    let html_filename = "happyHour.html".to_string();
    if email.unpack_html(&unpack_dir, &html_filename, &parts_subdir).is_err() {
        println!("{}", email.last_error_text());
        return;
    }

    println!("Success.");
}