added html template with attachment

main
Nickiel12 1 year ago
parent 24b29f2bbd
commit 02b7127d30

@ -365,18 +365,43 @@ fn send_email_summary(config: &Config, body_content: Vec<String>) {
let attachment = Attachment::new("TimeSummary.csv".to_string()).body(data, ContentType::parse("text/csv").unwrap());
const HTML: &str = r#"
!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello from Lettre!</title>
</head>
<body>
<div style="display: flex; flex-direction: column; align-items: center;">
<h2 style="font-family: Arial, Helvetica, sans-serif;">Hello from Lettre!</h2>
<h4 style="font-family: Arial, Helvetica, sans-serif;">A mailer library for Rust</h4>
</div>
</body>
</html>"#;
let email = Message::builder()
.from("NoReplay <noreply@nickiel.net>".parse().unwrap())
.to("Nicholas Young <nicholasyoungsumner@gmail.com>".parse().unwrap())
.from("NoReply@nickiel.net <noreply@nickiel.net>".parse().unwrap())
.to(config.email_addr.parse().unwrap())
.subject("Testing email")
.header(ContentType::TEXT_PLAIN)
.singlepart(attachment)
.unwrap();
// .multipart(
// MultiPart::mixed()
// .singlepart(SinglePart::plain("Hello World".to_string()))
// .singlepart(attachment)
// ).unwrap();
.multipart(
MultiPart::mixed()
.multipart(
MultiPart::alternative()
.singlepart(
SinglePart::builder()
.header(ContentType::TEXT_PLAIN)
.body(String::from("Hello world"))
)
.singlepart(
SinglePart::builder()
.header(ContentType::TEXT_HTML)
.body(String::from(HTML))
)
)
.singlepart(attachment)
).unwrap();
let mailer = SendmailTransport::new();

Loading…
Cancel
Save