-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathautomail.py
34 lines (30 loc) · 859 Bytes
/
automail.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import yagmail
import os
import datetime
import Info
import pandas as pd
import numpy as np
date = datetime.date.today().strftime("%B %d, %Y")
path = 'Attendance'
os.chdir(path)
files = sorted(os.listdir(os.getcwd()), key=os.path.getmtime)
df = pd.read_csv(r'EmployeeDetails\EmployeeDetails.csv')
receivers = df["email"]
newest = files[-1]
filename = newest
sub = "Attendance Report for " + str(date)
body = " Attendance Submitted."
for receiver in receivers:
# mail information
if pd.isnull(reciver):
continue
else:
yag = yagmail.SMTP(Info.EMAIL_ID, Info.PASSWORD)
# sent the mail
yag.send(
to=receiver,
subject=sub, # email subject
contents=body, # email body
attachments= filename # file attached
)
print("Email Sent to "+reciver)