Rust
Rust
MIME Multipart Boundary and Preamble Properties
See more MIME Examples
Demonstrates the Boundary property, which gets or sets the raw boundary token of a multipart entity (without surrounding quotation marks), and UseMmDescription, which controls whether the conventional preamble text is emitted when serializing a multipart entity.
Background. A multipart boundary separates the constituent parts. Chilkat quotes the token automatically in the header when required. The preamble is ignored by MIME-aware readers and is off by default.
Chilkat Rust Downloads
let mime = chilkat::Mime::new();
// Create a multipart/mixed entity.
if mime.new_multipart_mixed().is_err() {
println!("{}", mime.last_error_text());
return;
}
// Boundary is the raw boundary token, without surrounding quotation marks. Chilkat quotes it
// automatically in the serialized header when required.
mime.set_boundary("example-boundary");
// UseMmDescription controls whether the conventional preamble text
// "This is a multi-part message in MIME format." is emitted. The default is false.
mime.set_use_mm_description(true);
// Add a simple part so the multipart has content.
let part = chilkat::Mime::new();
if part.set_body_from_plain_text("First part.").is_err() {
println!("{}", part.last_error_text());
return;
}
if mime.append_part(&part).is_err() {
println!("{}", mime.last_error_text());
return;
}
println!("Boundary = {}", mime.boundary());
let Ok(mime_str) = mime.get_mime() else {
println!("{}", mime.last_error_text());
return;
};
println!("{}", mime_str);