# import required packagesimportpandasaspdimportdatetimeimportsmtplibimporttimeimportrequestsfromwin10toastimportToastNotifier# your gmail credentials hereGMAIL_ID='your_email_here'GMAIL_PWD='your_password_here'# for desktop notificationtoast=ToastNotifier()# define a function for sending emaildefsendEmail(to,sub,msg):# connection to gmailgmail_obj=smtplib.SMTP('smtp.gmail.com',587)# starting the sessiongmail_obj.starttls()# login using credentialsgmail_obj.login(GMAIL_ID,GMAIL_PWD)# sending emailgmail_obj.sendmail(GMAIL_ID,to,f"Subject :{sub}\n\n{msg}")# quit the sessiongmail_obj.quit()print("Email sent to "+str(to)+" with subject "+str(sub)+" and message :"+str(msg))toast.show_toast("Email Sent!",f"{name} was sent e-mail",threaded=True,icon_path=None,duration=6)whiletoast.notification_active():time.sleep(0.1)# define a function for sending smsdefsendsms(to,msg,name,sub):url="https://www.fast2sms.com/dev/bulk"payload=f"sender_id=FSTSMS&message={msg}&language=english&route=p&numbers={to}"headers={'authorization':"API_KEY_HERE",'Content-Type':"application/x-www-form-urlencoded",'Cache-Control':"no-cache",}response_obj=requests.request("POST",url,data=payload,headers=headers)print(response_obj.text)print("SMS sent to "+str(to)+" with subject :"+str(sub)+" and message :"+str(msg))toast.show_toast("SMS Sent!",f"{name} was sent message",threaded=True,icon_path=None,duration=6)whiletoast.notification_active():time.sleep(0.1)# driver codeif__name__=="__main__":# read the excel sheet having all the detailsdataframe=pd.read_excel("excelsheet.xlsx")# today date in format : DD-MMtoday=datetime.datetime.now().strftime("%d-%m")# current year in format : YYyearNow=datetime.datetime.now().strftime("%Y")# writeindex listwriteInd=[]forindex,itemindataframe.iterrows():msg="Many Many Happy Returns of the day dear "+str(item['NAME'])# stripping the birthday in excel# sheet as : DD-MMbday=item['Birthday'].strftime("%d-%m")# condition checkingif(today==bday)andyearNownotinstr(item['Year']):# calling the sendEmail functionsendEmail(item['Email'],"Happy Birthday",msg)# calling the sendsms functionsendsms(item['Contact'],msg,item['NAME'],"Happy Birthday")writeInd.append(index)foriinwriteInd:yr=dataframe.loc[i,'Year']# this will record the years in which# email has been sentdataframe.loc[i,'Year']=str(yr)+','+str(yearNow)dataframe.to_excel('excelsheet.xlsx',index=False)