forked from avinashkranjan/Amazing-Python-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
44 lines (38 loc) · 1.32 KB
/
main.py
File metadata and controls
44 lines (38 loc) · 1.32 KB
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
35
36
37
38
39
40
41
42
43
44
import pandas as pd
import smtplib
from email.message import EmailMessage
import xlrd
import openpyxl
import time
# Variable Declarations
excelFile = "DemoExcelFile.xlsx" # Email Data
emailID = "abc@gmail.com" # Add MailID
pwd = "abc@7" # Add PASSWORD
subject = "We're Back!, Walk With World KITCOEK" # EMAIL SUBJECT
htmlfile_loc = "camp1.html" # YOUR HTML FILE
# Reading File
file = pd.ExcelFile(excelFile, engine='openpyxl')
# Email Setup
s = smtplib.SMTP("smtp.gmail.com", 587)
s.starttls() # Traffic encryption
s.login(emailID, pwd) # SMTP Login
count = 0
for sheet in file.sheet_names:
print("\n\n<-- New Sheet -->\n")
df1 = file.parse(sheet)
for i in range(len(df1['EMAIL'])):
with open(htmlfile_loc, 'r', encoding='utf8') as file:
html_Content = str(file.read())
msg = EmailMessage()
msg['Subject'] = subject
msg['From'] = emailID
msg['To'] = df1['EMAIL'][i]
msg.add_alternative(html_Content, subtype="html")
s.send_message(msg)
count += 1
print(">>> ", df1['SRNO'][i], ": ", df1['EMAIL'][i], " : Sent")
if (count % 60 == 0):
print("\n\n <<>> Server CoolDown for 60 seconds <<>>\n\n")
time.sleep(10)
s.quit()
print("\n\n <<:>> All Emails Sent <<:>>\n\n")