forked from shuvamdas/Auto-Mailer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (25 loc) · 849 Bytes
/
main.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
import smtplib
from body import emailbody
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
import pandas as pd
e = pd.read_excel("data.xlsx")
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('sr1498@srmist.edu.in','password')
body = emailbody
subject = "Gen-Y Webinar Certificate of Participation"
fromaddr='sr1498@srmist.edu.in'
for index, row in e.iterrows():
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['Subject'] = subject
msg.attach(MIMEText(body, 'plain'))
filename = row["image"]
toaddr = row["emails"]
msg.attach(MIMEImage(open(filename, 'rb').read()))
server.sendmail(fromaddr, toaddr, msg.as_string())
print(str(index+1)+"sent")
print(str(index+1)+" Emails sent successfully")
server.quit()