qr_code/
qr_code.rs

1use templateless::{
2	components::{Image, Service, SocialItem, StoreBadge, StoreBadgeItem},
3	utils, Content, Email, EmailAddress, Footer, Header, Result, Templateless,
4	Theme,
5};
6
7#[tokio::main]
8async fn main() -> Result<()> {
9	let api_key = utils::get_env("TEMPLATELESS_API_KEY");
10	let email_address = utils::get_env("TEMPLATELESS_EMAIL_ADDRESS");
11
12	let header = Header::builder()
13		.component(
14			Image::new("https://templateless.net/myco.webp")
15				.width(100)
16				.alt("MyCo")
17				.build()?,
18		)
19		.build()?;
20
21	let app_store_link = "https://apps.apple.com/us/app/example/id1234567890";
22	let google_play_link =
23		"https://play.google.com/store/apps/details?id=com.example";
24
25	let footer = Footer::builder()
26		.store_badges(&[
27			StoreBadgeItem::new(StoreBadge::AppStore, app_store_link),
28			StoreBadgeItem::new(StoreBadge::GooglePlay, google_play_link),
29		])
30		.socials(&[
31			SocialItem::new(Service::Twitter, "MyCo"),
32			SocialItem::new(Service::GitHub, "MyCo"),
33		])
34		.build()?;
35
36	let content = Content::builder()
37        .theme(Theme::Simple)
38		.header(header)
39		.text("Hey Alex,")
40		.text("Thank you for choosing MyCo! To get started with our mobile experience, simply pair your account with our mobile app.")
41        .text("Here's how to do it:")
42		.text(&[
43            &format!("1. Download the MyCo app from the [App Store]({app_store_link}) or [Google Play]({google_play_link})."),
44            "1. Open the app and select _Pair Device_.",
45            "1. Scan the QR code below with your mobile device:",
46        ].join("\n"))
47        .qr_code("https://example.com/qr-code-link")
48		.text("Enjoy your seamless experience across devices!")
49		.footer(footer)
50		.build()?;
51
52	let email = Email::builder()
53		.to(EmailAddress::new(&email_address))
54		.subject("How to Pair Device")
55		.content(content)
56		.build()?;
57
58	let templateless = Templateless::new(&api_key);
59	let _ = templateless.send(email).await?;
60
61	Ok(())
62}