1
- import pandas as pd # Pandas library is used for importing and reading the data
2
- import datetime # datetime module is used for fetching the dates
1
+ # Pandas library is used for importing and reading the data
2
+ import pandas as pd
3
+ # datetime module is used for fetching the dates
4
+ import datetime
3
5
import smtplib # smtp library used for sending mail
4
6
import os
5
7
6
8
current_path = os .getcwd ()
7
9
print (current_path )
8
- os .chdir (current_path ) # Changing the Path of the directory in which you are currently working
10
+ # Changing the Path of the directory in which you are currently working
11
+ os .chdir (current_path )
9
12
10
- GMAIL_ID = input ("Enter your email: " ) # Give your mail here from which you want to send the wishes
11
- GMAIL_PSWD = input ("Enter password for your email mentioned above: " ) # Give your mail password
13
+ # Give your mail here from which you want to send the wishes
14
+ GMAIL_ID = input ("Enter your email: " )
15
+ # Give your mail password
16
+ GMAIL_PSWD = input ("Enter password for your email mentioned above: " )
12
17
13
18
14
19
def sendEmail (to , sub , msg ):
15
20
print (f"Email to { to } sent: \n Subject: { sub } ,\n Message: { msg } " )
16
- s = smtplib .SMTP ('smtp.gmail.com' , 587 ) # creating server to send mail
17
- s .starttls () # start a TLS session
18
- s .login (GMAIL_ID , GMAIL_PSWD ) # the function will login with your Gmail credentials
19
- s .sendmail (GMAIL_ID , to , f"Subject: { sub } \n \n { msg } " ) # sending the mail
21
+ # creating server to send mail
22
+ s = smtplib .SMTP ('smtp.gmail.com' , 587 )
23
+ # start a TLS session
24
+ s .starttls ()
25
+ # the function will login with your Gmail credentials
26
+ s .login (GMAIL_ID , GMAIL_PSWD )
27
+ # sending the mail
28
+ s .sendmail (GMAIL_ID , to , f"Subject: { sub } \n \n { msg } " )
20
29
s .quit ()
21
30
22
31
23
32
if __name__ == "__main__" :
24
- df = pd .read_excel ("data.xlsx" ) # the datasheet where the data of the friends is stored
33
+ # the datasheet where the data of the friends is stored
34
+ df = pd .read_excel ("data.xlsx" )
25
35
today = datetime .datetime .now ().strftime ("%d-%m" )
26
36
yearNow = datetime .datetime .now ().strftime ("%Y" )
27
37
@@ -31,7 +41,8 @@ def sendEmail(to, sub, msg):
31
41
bday = datetime .datetime .strptime (bday , "%d-%m-%Y" )
32
42
bday = bday .strftime ("%d-%m" )
33
43
if (today == bday ) and yearNow not in str (item ['LastWishedYear' ]):
34
- sendEmail (item ['Email' ], "Happy Birthday" , item ['Dialogue' ]) # calling the sendmail function
44
+ # calling the sendmail function
45
+ sendEmail (item ['Email' ], "Happy Birthday" , item ['Dialogue' ])
35
46
writeInd .append (index )
36
47
37
48
if writeInd != None :
0 commit comments