I want to send an email using python. The contents of the message is from a sql querry placed inside a ttk treeview widget. so how do i select and send the selected items? the code below prints (I001) inside the email.
# Specifying the from and to addresses
self.fromaddr = 'remlaproductions@gmail.com'
self.toaddrs = 'draedarockstar@gmail.com'
self.subject = 'EMP Info'
# Writing the message (this message will appear in the email)
self.msg =" %s "%(self.tree.selection())
# Gmail Login
self.username = 'remlaproductions'
self.password = 'draedarockstar'
#Sending Email
try:
self.server = smtplib.SMTP('smtp.gmail.com',587)
self.server.ehlo()
self.server.starttls()
self.server.ehlo()
self.server.login(self.username,self.password)
self.server.sendmail(self.fromaddr, self.toaddrs, self.msg)
messagebox.showinfo(title = "Email Update", message = "Email Sent")
print(self.tree.selection())
except:
messagebox.showinfo(title = "Email Update", message = "Error sending email")
self.server.quit()
thanks in advance for your help