Rust
Rust
Outlook -- Delete Folder
See more Outlook Examples
Deletes an email folder.Note: This example requires Chilkat v9.5.0.68 or greater.
This example applies to: Exchange Online | Office 365 | Hotmail.com | Live.com | MSN.com | Outlook.com | Passport.com
Chilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
// Use your previously obtained access token here:
http.set_auth_token("MICROSOFT_GRAPH_ACCESS_TOKEN");
// This example will delete the folder /Inbox/abc/subFolderC
// Get the existing folder ID from the folder map created by this example
let ht_folder_map = chilkat::Hashtable::new();
let sb_map = chilkat::StringBuilder::new();
let _ = sb_map.load_file("qa_data/outlook/folderMap.xml", "utf-8");
let _ = ht_folder_map.add_from_xml_sb(&sb_map);
let Ok(existing_folder_id) = ht_folder_map.lookup_str("/Inbox/abc/subFolderC") else {
println!("Folder ID not found");
return;
};
let _ = http.set_url_var("folder_id", &existing_folder_id);
let Ok(resp) = http.quick_delete_str("https://graph.microsoft.com/v1.0/me/mailFolders/{$folder_id}") else {
println!("{}", http.last_error_text());
return;
};
// A 204 response (with no response body) indicates success.
if http.last_status() == 204 {
println!("Folder deleted.");
} else {
println!("Folder not deleted.");
println!("{}", resp);
}