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

POP3 Fetch Mime Source of Email by UIDL

Demonstrates how to fetch the MIME source of a single email by UIDL.

Chilkat Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let mailman = chilkat::MailMan::new();

mailman.set_mail_host("pop.example.com");

mailman.set_pop_username("myLogin");
mailman.set_pop_password("myPassword");

mailman.set_mail_port(995);
mailman.set_pop_ssl(true);

let st_uidls = chilkat::StringTable::new();
if mailman.fetch_uidls(&st_uidls).is_err() {
    println!("{}", mailman.last_error_text());
    return;
}

// Download each email as MIME.
let bd_mime = chilkat::BinData::new();

let count = st_uidls.count();
let mut i = 0;
while i < count {
    if mailman.fetch_mime_bd(&st_uidls.string_at(i).unwrap_or_default(), &bd_mime).is_err() {
        println!("{}", mailman.last_error_text());
        return;
    }

    // Do whatever is needed with the MIME contained in bdMime.

    i = i + 1;
}