added html template with attachment
This commit is contained in:
parent
24b29f2bbd
commit
02b7127d30
1 changed files with 35 additions and 10 deletions
|
@ -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());
|
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()
|
let email = Message::builder()
|
||||||
.from("NoReplay <noreply@nickiel.net>".parse().unwrap())
|
.from("NoReply@nickiel.net <noreply@nickiel.net>".parse().unwrap())
|
||||||
.to("Nicholas Young <nicholasyoungsumner@gmail.com>".parse().unwrap())
|
.to(config.email_addr.parse().unwrap())
|
||||||
.subject("Testing email")
|
.subject("Testing email")
|
||||||
|
.multipart(
|
||||||
|
MultiPart::mixed()
|
||||||
|
.multipart(
|
||||||
|
MultiPart::alternative()
|
||||||
|
.singlepart(
|
||||||
|
SinglePart::builder()
|
||||||
.header(ContentType::TEXT_PLAIN)
|
.header(ContentType::TEXT_PLAIN)
|
||||||
|
.body(String::from("Hello world"))
|
||||||
|
)
|
||||||
|
.singlepart(
|
||||||
|
SinglePart::builder()
|
||||||
|
.header(ContentType::TEXT_HTML)
|
||||||
|
.body(String::from(HTML))
|
||||||
|
)
|
||||||
|
)
|
||||||
.singlepart(attachment)
|
.singlepart(attachment)
|
||||||
.unwrap();
|
).unwrap();
|
||||||
// .multipart(
|
|
||||||
// MultiPart::mixed()
|
|
||||||
// .singlepart(SinglePart::plain("Hello World".to_string()))
|
|
||||||
// .singlepart(attachment)
|
|
||||||
// ).unwrap();
|
|
||||||
|
|
||||||
|
|
||||||
let mailer = SendmailTransport::new();
|
let mailer = SendmailTransport::new();
|
||||||
|
|
Loading…
Reference in a new issue