Rust
Rust
Email Body - Plain Text and/or HTML
Any given email may have a plain-text body, an HTML body, or both. The Body property will return the HTML body by default (if it exists) otherwise it will return the plain-text body. There are methods for checking to see if an email has a particular body (HasPlainTextBody and HasHtmlBody) and there are methods for getting a specific body: GetHtmlBody, GetPlainTextBody.Chilkat Rust Downloads
let email = chilkat::Email::new();
// Load an email from a .eml
if email.load_eml("something.eml").is_err() {
println!("{}", email.last_error_text());
return;
}
// Display the default Body:
println!("{}", email.body());
// If a plain-text body is present, display it:
let b_text = email.has_plain_text_body();
if b_text {
println!("{}", email.get_plain_text_body().unwrap_or_default());
}
// If an HTML body is present, display the HTML source:
let b_html = email.has_html_body();
if b_html {
println!("{}", email.get_html_body().unwrap_or_default());
}