Send emails from sheet
Tags: #gsheet #data #naas_drivers
Author: Jeremy Ravenel

Input

Import librairies

1
from naas_drivers import gsheet
2
from naas_drivers import email
Copied!

Variables

1
username = "USERNAME"
2
password = "PASSWORD"
3
email_from = "***@cashstory.com",
4
smtp_server = "smtp.gmail.com",
5
smtp_port = 465,
6
smtp_type = "SSL",
Copied!

Model

Connect to your gmail account

1
gmail = emails.connect(username,
2
password,
3
email_from,
4
smtp_server,
5
smtp_port,
6
smtp_type)
Copied!

Get email list from Gsheet

1
spreadsheet_id = "1s-TQZrevbmveFKlx2H49fgvr_nZPEY_ffoi0iWal**E"
2
sheet_name = "********"
3
4
df = gsheet.connect(spreadsheet_id).get(sheet_name)
5
df
Copied!
1
emails = df['EMAIL'].drop_duplicates().values
2
print(emails)
Copied!

Output

Send emails batchs

1
subject = "The tesla action is going up"
2
content = "check in the link the chart data maide from fresh dataset : [LINK]"
3
4
for email in emails:
5
print(email)
6
# gmail.send(email_to=email, subject=subject, html=content)
Copied!
Copy link
Edit on GitHub