Rust Requires Chilkat v11.0.0+
Rust
Read POP3 Mail Headers
Reads the header for each email in a POP3 mailbox and display the FROM and SUBJECT header fields.Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// The mailman object is used for receiving (POP3)
// and sending (SMTP) email.
let mailman = chilkat::MailMan::new();
// Set the POP3 server's hostname
mailman.set_mail_host("pop.example.com");
// Set the POP3 login/password.
mailman.set_pop_username("****");
mailman.set_pop_password("****");
// Read mail headers and one line of the body.
let bundle = chilkat::EmailBundle::new();
let keep_on_server = true;
let headers_only = true;
let num_body_lines = 1;
if mailman.fetch_all(keep_on_server, headers_only, num_body_lines, &bundle).is_err() {
println!("{}", mailman.last_error_text());
return;
}
let email = chilkat::Email::new();
let mut i = 0;
while i < bundle.message_count() {
let _ = bundle.email_at(i, &email);
// Display the From email address and the subject.
println!("From: {}", email.from());
println!("Subject: {}", email.subject());
i = i + 1;
}