Rust Requires Chilkat v11.0.0+
Rust
Find the "Sent" IMAP Mailbox
See more IMAP Examples
Find the "Sent" IMAP mailbox. Also finds the Junk and Trash mailboxes..Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let imap = chilkat::Imap::new();
imap.set_ssl(true);
imap.set_port(993);
if imap.connect("imap.yourmailserver.com").is_err() {
println!("{}", imap.last_error_text());
return;
}
// Login or authenticate in some way..
if imap.login("your_login", "your_password").is_err() {
println!("{}", imap.last_error_text());
return;
}
// Get the list of mailboxes.
let ref_name = String::new();
let wildcarded_mailbox = "*".to_string();
let subscribed = false;
let mboxes = chilkat::Mailboxes::new();
if imap.mbx_list(subscribed, &ref_name, &wildcarded_mailbox, &mboxes).is_err() {
println!("{}", imap.last_error_text());
return;
}
// The mailbox with the "/Sent" flag is the "Sent" mailbox.
// Likewise for Junk and Trash..
let mut i = 0;
while i < mboxes.count() {
if mboxes.has_flag(i, "\\Sent") {
println!("Sent mailbox: {}", mboxes.get_name(i).unwrap_or_default());
}
if mboxes.has_flag(i, "\\Junk") {
println!("Junk mailbox: {}", mboxes.get_name(i).unwrap_or_default());
}
if mboxes.has_flag(i, "\\Trash") {
println!("Trash mailbox: {}", mboxes.get_name(i).unwrap_or_default());
}
i = i + 1;
}
// Disconnect from the IMAP server.
let _ = imap.disconnect().is_ok();