Python email reminders made easy!

I started learning python this year. On my code academy course I had a project to do, and wanted to make something more practical. In the example they had a list of five menus they could pull from in their interactive Python code. I thought that was a great idea because it was more practical, but I wanted to do something else.

I realized that a reminder maker would be really helpful for every day of the week because I was thinking about ways to remind myself of things as well as schedule them. So I went about figuring out how to do it.

import time # Title for the email reminder maker. DON'T USE THE SAME TITLE NAME. print(""" ###### # # ##### ##### # # ###### #### # # # # # ## # # # # # # ###### # # # ## # ###### ###### # # # # # ## # # # # # # ###### # # ##### ##### # # ###### #### ------------------------------------------------------------------- Welcome to Em Sched! ------------------------------------------------------------------- A txt reminder maker. You have the option to add or remove reminders for every day of the week. """) # Class that can open files and print the text in them to the terminal. class remin(): def __init__(self, fils): self.fil = fils def remindstat(self): file1 = open(self.fil, "r") print("\n" + file1.read()) print() file1.close() # Class that can open files and write new reminders in them. class reminder(): def __init__(self, day, file, reminder): self.day = day self.file = file self.reminder = reminder def makereminder(self): time.sleep(1) file1 = open(self.file, "a") # append mode file1.write(self.reminder + "\n") file1.close() day = input("what day would you like to have a reminder? [mon/exit] ") #looping so you can make as many reminders as you want for any day each time you run the program. while day == "mon" or "tue" or "wed" or "thu" or "fri" or "sat" or "sun": #creating a file for a day of the week that is imported into the email. if day == "mon": f = "monday.txt" stat = remin(f) stat.remindstat() re = input("What would you like to add to monday's reminder? ") daily = reminder(day, f, re) daily.makereminder() stat.remindstat() day = input("what day would you like to have a reminder? [mon/exit] ") continue #creating a file for a day of the week that is imported into the email. elif day == "tue": f = "tuesday.txt" stat = remin(f) stat.remindstat() re = input("What would you like to add to tuesday's reminder? ") daily = reminder(day, f, re) daily.makereminder() stat.remindstat() day = input("what day would you like to have a reminder? [mon/exit] ") continue #creating a file for a day of the week that is imported into the email. elif day == "wed": f = "wednesday.txt" stat = remin(f) stat.remindstat() re = input("What would you like to add to wednesday's reminder? ") daily = reminder(day, f, re) daily.makereminder() stat.remindstat() day = input("what day would you like to have a reminder? [mon/exit] ") continue #creating a file for a day of the week that is imported into the email. elif day == "thu": f = "thursday.txt" stat = remin(f) stat.remindstat() re = input("What would you like to add to thursday's reminder? ") daily = reminder(day, f, re) daily.makereminder() stat.remindstat() day = input("what day would you like to have a reminder? [mon/exit] ") continue #creating a file for a day of the week that is imported into the email. elif day == "fri": f = "friday.txt" stat = remin(f) stat.remindstat() re = input("What would you like to add to friday's reminder? ") daily = reminder(day, f, re) daily.makereminder() stat.remindstat() day = input("what day would you like to have a reminder? [mon/exit] ") continue #creating a file for a day of the week that is imported into the email. elif day == "sat": f = "saturday.txt" stat = remin(f) stat.remindstat() re = input("What would you like to add to saturday's reminder? ") daily = reminder(day, f, re) daily.makereminder() stat.remindstat() day = input("what day would you like to have a reminder? [mon/exit] ") continue #creating a file for a day of the week that is imported into the email. elif day == "sun": f = "sunday.txt" stat = remin(f) stat.remindstat() re = input("What would you like to add to sunday's reminder? ") daily = reminder(day, f, re) daily.makereminder() stat.remindstat() day = input("what day would you like to have a reminder? [mon/exit] ") continue else: break def d(na, nu): # opens the file, reads and stores each line into a list with open(na) as file: lines = file.readlines() # if the line number is in the file, we can delete it if (nu <= len(lines)): # delete the line from the list, which will be at line_number - 1 because # lists are zero-indexed in Python del lines[nu - 1] # open the file for writing with "w" which will make the file blank with open(na, "w") as file: # write as the new content of the file, the remaining lines in the list for line in lines: file.write(line) #if the line number exceeds the length of the file, output an error message else: # inform the user the line is not in the file, and how many lines there is print("Line", nu, "not in file.") print("File has", len(lines), "lines.") days = input("\n" + "what day do you want to delete a reminder from? [mon/exit] ") #looping so you can remove as many reminders as you want for any day each time you run the program. while days == "mon" or "tue" or "wed" or "thu" or "fri" or "sat" or "sun": # Editing a file for a day of the week that removes reminders. if days == "mon": df = "monday.txt" sta = remin(df) sta.remindstat() time.sleep(1) dl = int(input("Line: ")) d(df, dl) time.sleep(1) sta.remindstat() time.sleep(1) days = input("What day do you want to delete a reminder from? [mon/exit] ") continue # Editing a file for a day of the week that removes reminders. elif days == "tue": df = "tuesday.txt" sta = remin(df) sta.remindstat() time.sleep(1) dl = int(input("Line: ")) d(df, dl) time.sleep(1) sta.remindstat() time.sleep(1) days = input("What day do you want to delete a reminder from? [mon/exit] ") continue # Editing a file for a day of the week that removes reminders. elif days == "wed": df = "wednesday.txt" sta = remin(df) sta.remindstat() time.sleep(1) dl = int(input("Line: ")) d(df, dl) time.sleep(1) sta.remindstat() time.sleep(1) days = input("What day do you want to delete a reminder from? [mon/exit] ") continue # Editing a file for a day of the week that removes reminders. elif days == "thu": df = "thursday.txt" sta = remin(df) sta.remindstat() time.sleep(1) dl = int(input("Line: ")) d(df, dl) time.sleep(1) sta.remindstat() time.sleep(1) days = input("What day do you want to delete a reminder from? [mon/exit] ") continue # Editing a file for a day of the week that removes reminders. elif days == "fri": df = "friday.txt" sta = remin(df) dl = int(input("Line: ")) d(df, dl) time.sleep(1) sta.remindstat() time.sleep(1) days = input("What day do you want to delete a reminder from? [mon/exit] ") continue # Editing a file for a day of the week that removes reminders. elif days == "sat": df = "saturday.txt" sta = remin(df) sta.remindstat() time.sleep(1) dl = int(input("Line: ")) d(df, dl) time.sleep(1) sta.remindstat() time.sleep(1) days = input("What day do you want to delete a reminder from? [mon/exit] ") continue # Editing a file for a day of the week that removes reminders. elif days == "sun": df = "sunday.txt" sta = remin(df) sta.remindstat() time.sleep(1) dl = int(input("Line: ")) d(df, dl) time.sleep(1) sta.remindstat() time.sleep(1) days = input("What day do you want to delete a reminder from? [mon/exit] ") continue else: break

Em Shed the way to make txts for reminder emails!

The first gif show how the user makes a reminder. They enter the fist three letters of the day. When the code running and it gets this prompt fulfilled, it runs a while loops that opens the txt file for that day and prints it to the terminal. Then the user gets to add their reminder and the loop prints the txt file again to the terminal.

Em Shed the way to remove reminders from a reminder txt as well!

The second gif show how the user removes reminder. They enter the fist three letters of the day. When the code running it gets this prompt fulfilled, it runs a while loops that opens the txt file for that day and prints it to the terminal. Then the user types what line they want to remove the reminder from and the loop prints the txt file again to the terminal.

Python Email File for Monday.

After making the txt editor I found a way to email my self the reminder. I set up two step verification on my gmail account and added an app password for python. I then put the password I got from the app password for python in the password field and my email in the email fields in my python email sender file for each day.

Python clear and reformat file.

I next made a clear python file that opens each txt and reformats it to the way it was on the first day of the week.

To finish it all up I set up crontab to run my email files to send myself reminders for every day of the week. I also had it run the clear file to clear and reformat the file at the beginning of every week.

https://github.com/lukeskywalker1890/Email_Reminders.git

It was a fun project to do. I enjoyed making something that was more practical and something I can use in the future. I showed how to make txt files that you can email as reminders.

How do you fix EOF errors?