Rust Requires Chilkat v11.0.0+
Rust
Forward an email as an attachment
See more Email Object Examples
Attach the original Email to a new message as a message/rfc822 part. The recipient can open the attached email and read its original headers and body.
Chilkat Rust Downloads
// Assumes Chilkat is unlocked. See Global Unlock Sample.
let original = chilkat::Email::new();
if original.load_eml("message.eml").is_err() {
println!("{}", original.last_error_text());
return;
}
let email = chilkat::Email::new();
email.set_from("Sam Lee <sam@example.com>");
if email.add_to("Alex Rivera", "alex@example.net").is_err() {
println!("{}", email.last_error_text());
return;
}
email.set_subject("Forwarded message");
email.set_body("The original email is attached.");
if email.attach_email(&original).is_err() {
println!("{}", email.last_error_text());
return;
}
if email.save_eml("forward-as-attachment.eml").is_err() {
println!("{}", email.last_error_text());
return;
}
println!("Saved forward-as-attachment.eml.");