Skip to content

Commit 5e55933

Browse files
Added Sorce code for Birthday_Manager.py and README.md
1 parent c64579a commit 5e55933

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

Automating Emails/Birthday-Manager.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import csv
2+
import smtplib, ssl
3+
4+
message="""Hi {fname}, Wish you a very Happy birthday.
5+
Hope you had a great time."""
6+
7+
sender_address="forpythonbirthdayproject@gmail.com"
8+
sender_password="qwerty@12345"
9+
10+
context = ssl.create_default_context()
11+
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
12+
server.login(sender_address,sender_password)
13+
14+
with open(r"C:\Users\sriva\OneDrive\Desktop\VS Code\Python\birthday.csv") as file:
15+
reader=csv.reader(file)
16+
next(reader)
17+
for fname,lname,email,dob in reader:
18+
server.sendmail(
19+
sender_address,
20+
email,
21+
message.format(fname=fname),
22+
)
23+
24+
add=input(
25+
"""Do you wish to add or remove names to the csv file?
26+
if you want add names type add
27+
otherwise if you want remove names type remove
28+
if you wish to exit, type exit
29+
"""
30+
)
31+
32+
if add=="add":
33+
new_data=input("Enter data as first name,lastname,email,date of birth: ")
34+
new_data=new_data.split(",")
35+
with open(r"C:\Users\sriva\OneDrive\Desktop\VS Code\Python\birthday.csv",'r+') as file:
36+
writer_object=csv.writer(file)
37+
next(file)
38+
writer_object.writerow(new_data)
39+
elif add=="remove":
40+
lines=[]
41+
removal=input("Enter the first name of the person to be removed: ")
42+
with open(r"C:\Users\sriva\OneDrive\Desktop\VS Code\Python\birthday.csv",'r') as file:
43+
reader=csv.reader(file)
44+
for row in reader:
45+
lines.append(row)
46+
for fields in row:
47+
if fields==removal:
48+
lines.remove(row)
49+
with open(r"C:\Users\sriva\OneDrive\Desktop\VS Code\Python\birthday.csv",'w',newline="") as file:
50+
writer=csv.writer(file)
51+
writer.writerows(lines)
52+
53+
54+
55+

Automating Emails/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Automating-Emails-on-a-.csv-file
2+
<hr>
3+
Python program to automate an email personalized birthday message by reading details from a .csv file<br>
4+
Also includes options to add and remove details from said .csv file

Automating-Emails-on-a-.csv-file

0 commit comments

Comments
 (0)