Links

Automate response from keywords in mailbox

Tags: #gmail #productivity #naas_drivers #operations #snippet
Author: Sanjay Sabu

Input

Import librairies

import naas
from naas_drivers import email
from re import search

Account credentials

username = "**********@gmail.com"
to = "**********@gmail.com"
password = "**********"
smtp_server = "imap.gmail.com"
box = "INBOX"

Model

Connect to email box

emails = email.connect(username,
password,
username,
smtp_server)

Get email list

dataframe = emails.get(criteria="ALL")
df

Output

Automated reponse

for df in dataframe["text"]:
text = df.lower()
if search("sales report", text):
email_to = "[email protected]"
subject = "Sales Report"
content = "Hi \n,Here I am attaching the sales report as per your request\n.With Regards\n,NAAS Team"
files = ["Excel-Sales_Feb2020.csv"]
naas.notifications.send(email_to=email_to, subject=subject, html=content, files=files)