Send email with different buttons how - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Send email with different buttons how (/thread-20580.html) |
Send email with different buttons how - chano - Aug-20-2019 This is my email, i have two buttons, one for cool water and one for hot water, i want like push cool water 10 times it send email, like push hot water 5 times to send email.Email working but like push cool button 5 times it send email, but after that like push buton hot only once it again send email, how i can fix this ,.Thank your help def Send_Email(email, password, to, subject, message): try: # Only for gmail account. with smtplib.SMTP('mail.xxxxxxxx.net:26') as server: server.ehlo() # local host server.starttls() # Puts the connection to the SMTP server. # login to the account of the sender server.login(email, password) # Format the subject and message together message = 'Subject: {}\n\n{}'.format(subject, message) # Sends the email from the logined email to the receiver's email server.sendmail(email, to, message) print('Email sent') except Exception as e: print("Email failed:",e) show_press = Label(master, text='You pressed the Button 0 times') show_press.pack() ##################### count = 0 def b1m(): ##this is name cool button global count count+=1 if count >= 5: # Code to be executed when "water is low" message = "adress ." Send_Email( email='@.net', # from account password='xxxxxx', #Its password to =("c@c"), # Receiver's email subject='water IS LOW PLEASE CHARGE1', # Subject of mail message=message ) # The message you want show_press['text'] = 'You pressed the Button {} times'.format(count) #end email count = 0 def b2m(): #name second hot button global count count+=1 if count >= 3: # Code to be executed when "water is low" message = "adress." Send_Email2( email='@', # from account password='xxxxx', #Its password to =("@" ), # Receiver's email subject='water IS LOW PLEASE CHARGE2', # Subject of mail message=message ) # The message you want show_press['text'] = 'You pressed the Button {} times'.format(count) RE: Send email with different buttons how - jefsummers - Aug-20-2019 Shouldn't you reset count to 0 when you send the email? |