-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
62 lines (47 loc) · 1.72 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pandas as pd
import smtplib
import openpyxl
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from docx import Document
from email.mime.base import MIMEBase
from email import encoders
contacts = pd.read_excel("contacts.xlsx")
your_email = "[email protected]"
your_password = "fqkf ceqb ahbk loip"
def get_email_body(file_path):
doc = Document(file_path)
return "\n".join([para.text for para in doc.paragraphs])
email_body_template = get_email_body("email_template.docx")
def send_email(receiver_name, company_name, job_link, receiver_email):
body = (
email_body_template.replace("{receiver_name}", receiver_name)
.replace("{company_name}", company_name)
.replace("{job_link}", job_link)
)
subject = "Application for SDE1 Role | IIIT Allahabad"
msg = MIMEMultipart()
msg["From"] = your_email
msg["To"] = receiver_email
msg["Subject"] = subject
msg.attach(MIMEText(body, "html"))
with open("Neeraj_Gupta_SDE1.pdf", "rb") as resume:
part = MIMEBase("application", "octet-stream")
part.set_payload(resume.read())
encoders.encode_base64(part)
part.add_header(
"Content-Disposition", f'attachment; filename="Neeraj_Gupta_SDE1.pdf"'
)
msg.attach(part)
with smtplib.SMTP("smtp.gmail.com", 587) as server:
server.starttls()
server.login(your_email, your_password)
server.send_message(msg)
print(f"Email sent to {receiver_name} ({receiver_email}) for {company_name}.")
for _, row in contacts.iterrows():
send_email(
row["Receiver Name"],
row["Company Name"],
row["Job Link"],
row["Receiver Email"],
)