Emailbuilder demo
Tags: #naas #emailbuilder #snippet
Author: Florent Ravenel

Input

Import libraries

1
import naas_drivers
2
import naas
3
import pandas as pd
Copied!

Variables

1
# List to emails address of the receiver(s)
2
email_to = [""]
3
4
# Email sender : Can only take your email account or [email protected]
5
email_from = ""
6
7
# Email subject
8
subject = "My Object"
Copied!

Model

Build the email

1
table = pd.DataFrame({
2
"Table Header 1": ["Left element 1", "Left element 2", "Left element 3"],
3
"Table Header 2": ["Right element 1", "Right element 2", "Right element 3"]
4
})
5
6
link = "https://www.naas.ai/"
7
8
img = "https://gblobscdn.gitbook.com/spaces%2F-MJ1rzHSMrn3m7xaPUs_%2Favatar-1602072063433.png?alt=media"
9
10
list_bullet = ["First element",
11
"Second element",
12
"Third element",
13
naas_drivers.emailbuilder.link(link, "Fourth element"),
14
]
15
16
footer_icons = [{
17
"img_src": img,
18
"href": link
19
}]
20
21
email_content = {
22
'element': naas_drivers.emailbuilder.title("This is a title"),
23
'heading': naas_drivers.emailbuilder.heading("This is a heading"),
24
'subheading': naas_drivers.emailbuilder.subheading("This is a subheading"),
25
'text': naas_drivers.emailbuilder.text("This is a text"),
26
'link': naas_drivers.emailbuilder.link(link, "This is a link"),
27
'button': naas_drivers.emailbuilder.button(link, "This is a button"),
28
'list': naas_drivers.emailbuilder.list(list_bullet),
29
'table': naas_drivers.emailbuilder.table(table, header=True, border=True),
30
'image': naas_drivers.emailbuilder.image(img),
31
'footer': naas_drivers.emailbuilder.footer_company(networks=footer_icons, company=["Company informations"], legal=["Legal informations"])
32
}
Copied!
1
content = naas_drivers.emailbuilder.generate(display='iframe',
2
**email_content)
Copied!

Output

Send the email

1
naas.notification.send(email_to=email_to,
2
subject=subject,
3
html=content,
4
email_from=email_from)
Copied!
Copy link
Edit on GitHub