I did some research here, I did see a similar question (Send formatted list of tuples as body of an email)
But my tuple is not a pair, my tuple is a SQL query result like:
mylist =[('Mike','Boston','32','doctor'),('kate','Boston','32','doctor')....]
Then I tried below format
body = "'%s,%s,%s,%s'"% (mylist[0],mylist[1],mylist[2],mylist[3])
But I receive an email with an empty body.
smtpObj.sendmail(sender, receivers, message)
Anything wrong with my code? Thank you for your help.
My code in email part is :
import smtplib
sender = 'xxxxxxx@gmail.com'
receivers = ['xxxxxxxx@gmail.com']
i=0
while (i<len(mylist)):
message ="'%s,%s,%s,%s'"% (mylist[0],mylist[1],mylist[2],mylist[3])
i=i+1
smtpObj = smtplib.SMTP('**********')
smtpObj.sendmail(sender, receivers, message)