Rust
Rust
Serialize MIME to a String
See more MIME Examples
Demonstrates the Chilkat Mime.GetMime method, which serializes and returns the complete MIME entity — headers, body, multipart boundaries, and all descendants — as a string. It takes no arguments.
Background: This produces the finished MIME text ready to send, store, or hand to another component — the inverse of loading. The whole tree is emitted, including generated multipart boundaries. Because it returns a string, it is best for text-safe content; when the body may contain raw binary bytes, serialize with
GetMimeBd to a BinData instead so nothing is altered.Chilkat Rust Downloads
// Demonstrates the Mime.GetMime method, which serializes and returns the complete MIME entity
// (headers, body, multipart boundaries, and all descendants) as a string. It takes no
// arguments.
let mime = chilkat::Mime::new();
// Build a simple MIME entity.
if mime.set_body_from_plain_text("Hello, this is the message body.").is_err() {
println!("{}", mime.last_error_text());
return;
}
// Serialize it to a string.
let Ok(mime_text) = mime.get_mime() else {
println!("{}", mime.last_error_text());
return;
};
println!("{}", mime_text);