How to forward attachments in a message #753
Answered
by
paolobarbolini
runqi-zhao
asked this question in
General
-
When I forward a message, the number of attachments in the message is dynamically obtained, how can I forward multiple attachments at once in the format of the sending message? |
Beta Was this translation helpful? Give feedback.
Answered by
paolobarbolini
Apr 6, 2022
Replies: 1 comment
-
Assuming your starting point is something like let m = Message::builder()
.from("NoBody <[email protected]>".parse()?)
.to("Hei <[email protected]>".parse()?)
.subject("Something")
// Rest of the headers...
// and then:
.multipart(MultiPart::alternative_plain_html(
String::from("Plaintext version of the body"),
String::from("Html version of the body"),
)); what you can do is change it to: let mut multipart = MultiPart::alternative_plain_html(
String::from("Plaintext version of the body"),
String::from("Html version of the body"),
);
for file in files_to_attach {
let attachment = Attachment::new(file_name).body(bytes, content_type); // build `Attachment` here
multipart = multipart.singlepart(attachment);
}
let m = Message::builder()
.from("NoBody <[email protected]>".parse()?)
.to("Hei <[email protected]>".parse()?)
.subject("Something")
// Rest of the headers...
// and then:
.multipart(multipart); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
runqi-zhao
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming your starting point is something like
what you can do is change it to: