Links

Send emails from sheet

Tags: #googlesheets #gsheet #data #naas_drivers #operations #snippet #email
Author: Jeremy Ravenel
Description: This notebook allows users to send emails directly from a Google Sheet.

Input

Import librairies

from naas_drivers import gsheet
from naas_drivers import email

Variables

username = "USERNAME"
password = "PASSWORD"
email_from = ("***@cashstory.com",)
smtp_server = ("smtp.gmail.com",)
smtp_port = (465,)
smtp_type = ("SSL",)

Model

Connect to your gmail account

gmail = emails.connect(
username, password, email_from, smtp_server, smtp_port, smtp_type
)

Get email list from Gsheet

spreadsheet_id = "1s-TQZrevbmveFKlx2H49fgvr_nZPEY_ffoi0iWal**E"
sheet_name = "********"
df = gsheet.connect(spreadsheet_id).get(sheet_name)
df
emails = df["EMAIL"].drop_duplicates().values
print(emails)

Output

Send emails batchs

subject = "The tesla action is going up"
content = "check in the link the chart data maide from fresh dataset : [LINK]"
for email in emails:
print(email)
# gmail.send(email_to=email, subject=subject, html=content)