-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterviewmail.py
More file actions
58 lines (43 loc) · 1.63 KB
/
interviewmail.py
File metadata and controls
58 lines (43 loc) · 1.63 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
def send_interview_emails():
import sqlite3
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
conn = sqlite3.connect('jd_cv_matching.db')
cursor = conn.cursor()
cursor.execute("""
SELECT
c.name,
sc.email,
jd.jd_title,
isch.interview_datetime
FROM shortlisted_candidates sc
JOIN candidates c ON sc.candidate_id = c.candidate_id
JOIN job_descriptions jd ON sc.jd_id = jd.jd_id
JOIN interview_schedule isch ON sc.candidate_id = isch.candidate_id AND sc.jd_id = isch.jd_id
""")
candidates = cursor.fetchall()
conn.close()
sender_email = "hriro894@gmail.com"
password = "ssxu gwrk dknc gyhw"
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(sender_email, password)
for name, email, job_title, interview_time in candidates:
message = MIMEMultipart()
message['From'] = sender_email
message['To'] = email
message['Subject'] = f"Interview Schedule for {job_title}"
body = f"""
Dear {name},
Congratulations! You have been shortlisted for the role of {job_title}.
Your interview is scheduled for: {interview_time}.
Please be available on time. Let us know if you have any questions.
Best regards,
HR Team
"""
message.attach(MIMEText(body, 'plain'))
server.send_message(message)
print(f" Email sent to {name} ({email})")
server.quit()
print("📬 All interview emails sent!")