Automate response from keywords in mailbox
Tags: #gmail #productivity #naas_drivers
Author: Sanjay Sabu

Input

Import librairies

1
import naas
2
from naas_drivers import email
3
from re import search
Copied!

Account credentials

1
username = "**********@gmail.com"
2
to = "**********@gmail.com"
3
password = "**********"
4
smtp_server = "imap.gmail.com"
5
box = "INBOX"
Copied!

Model

Connect to email box

1
emails = email.connect(username,
2
password,
3
username,
4
smtp_server)
Copied!

Get email list

1
dataframe = emails.get(criteria="ALL")
2
df
Copied!

Output

Automated reponse

1
for df in dataframe["text"]:
2
text = df.lower()
3
if search("sales report", text):
4
email_to = "[email protected]"
5
subject = "Sales Report"
6
content = "Hi \n,Here I am attaching the sales report as per your request\n.With Regards\n,NAAS Team"
7
files = ["Excel-Sales_Feb2020.csv"]
8
naas.notifications.send(email_to=email_to, subject=subject, html=content, files=files)
9
Copied!
Copy link
Edit on GitHub