diff --git a/time_tracker/src/main.rs b/time_tracker/src/main.rs index 696e4d9..4ea2a49 100644 --- a/time_tracker/src/main.rs +++ b/time_tracker/src/main.rs @@ -365,18 +365,43 @@ fn send_email_summary(config: &Config, body_content: Vec) { let attachment = Attachment::new("TimeSummary.csv".to_string()).body(data, ContentType::parse("text/csv").unwrap()); + const HTML: &str = r#" + !DOCTYPE html> + + + + + Hello from Lettre! + + +
+

Hello from Lettre!

+

A mailer library for Rust

+
+ +"#; + let email = Message::builder() - .from("NoReplay ".parse().unwrap()) - .to("Nicholas Young ".parse().unwrap()) + .from("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();