-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name,email,year,month,day | ||
test,[email protected],1961,12,21 | ||
[Fill this in!] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[.ShellClassInfo] | ||
IconResource=C:\My Icons\Cornmanthe3rd-Plex-Other-python.ico,0 | ||
[ViewState] | ||
Mode= | ||
Vid= | ||
FolderType=Generic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Dear [NAME], | ||
|
||
Happy birthday! | ||
|
||
All the best for the year! | ||
|
||
YJ-928 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Hey [NAME], | ||
|
||
Happy birthday! Have a wonderful time today and eat lots of cake! | ||
|
||
Lots of love, | ||
|
||
YJ-928 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Dear [NAME], | ||
|
||
It's your birthday! Have a great day! | ||
|
||
All my love, | ||
|
||
YJ-928 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#To run and test the code you need to update 4 places: | ||
# 1. Change MY_EMAIL/MY_PASSWORD to your own details. | ||
# 2. Go to your email provider and make it allow less secure apps. | ||
# 3. Update the SMTP ADDRESS to match your email provider. | ||
# 4. Update birthdays.csv to contain today's month and day. | ||
|
||
|
||
from datetime import datetime | ||
import pandas | ||
import random | ||
import smtplib | ||
|
||
MY_EMAIL = "YOUR EMAIL" | ||
MY_PASSWORD = "YOUR PASSWORD" | ||
|
||
today = datetime.now() | ||
today_tuple = (today.month, today.day) | ||
|
||
data = pandas.read_csv("birthdays.csv") | ||
birthdays_dict = {(data_row["month"], data_row["day"]): data_row for (index, data_row) in data.iterrows()} | ||
if today_tuple in birthdays_dict: | ||
birthday_person = birthdays_dict[today_tuple] | ||
file_path = f"letter_templates/letter_{random.randint(1,3)}.txt" | ||
with open(file_path) as letter_file: | ||
contents = letter_file.read() | ||
contents = contents.replace("[NAME]", birthday_person["name"]) | ||
|
||
with smtplib.SMTP("YOUR EMAIL PROVIDER SMTP SERVER ADDRESS") as connection: | ||
connection.starttls() | ||
connection.login(MY_EMAIL, MY_PASSWORD) | ||
connection.sendmail( | ||
from_addr=MY_EMAIL, | ||
to_addrs=birthday_person["email"], | ||
msg=f"Subject:Happy Birthday!\n\n{contents}" | ||
) |