Rust
Rust
Get a List of Message IDs in GMail User's Mailbox
See more GMail REST API Examples
Demonstrates how to get a list of message IDs in a GMail mailbox. The "userId" can be either the user's email address or the special value "me" to indicate the authenticated user.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();
http.set_auth_token("ACCESS_TOKEN");
http.set_accept("application/json");
let resp = chilkat::HttpResponse::new();
if http.http_no_body("GET", "https://www.googleapis.com/gmail/v1/users/userId/messages", &resp).is_err() {
println!("{}", http.last_error_text());
return;
}
println!("Response Status Code: {}", resp.status_code());
let json_response = chilkat::JsonObject::new();
let _ = json_response.load(&resp.body_str());
json_response.set_emit_compact(false);
println!("{}", json_response.emit().unwrap_or_default());
if resp.status_code() != 200 {
println!("Failed.");
return;
}
// {
// "messages": [
// users.messages Resource
// ],
// "nextPageToken": string,
// "resultSizeEstimate": unsigned integer
// }
let result_size_estimate = json_response.int_of("resultSizeEstimate");
let mut i = 0;
let count_i = json_response.size_of_array("messages");
while i < count_i {
json_response.set_i(i);
let _ = json_response.string_of("messages[i].id").unwrap_or_default();
let _ = json_response.string_of("messages[i].threadId").unwrap_or_default();
i = i + 1;
}