我已经使用tkinter GUI在python中创建了一个应用程序。 在这个应用程序中,我有一个按钮,当我点击它时,我想使用python的标准电子邮件库将我的数据库中的某些记录通过电子邮件发送给客户。但是我似乎只能发送1条记录......
我忽略了什么吗?
def Send_OC_Worksheet_Mail(self, event):
fromaddr = "my email address"
toaddr = "customer email address"
msg = MIMEMultipart()
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = "my subject"
Send_Jobs_List_Qry = (c.execute('SELECT Job_Description, Job_Date FROM Jobs WHERE Worksheet_Mailed=?', (0, ))).fetchall()
for Send_Jobs_List_Row in Send_Jobs_List_Qry:
Job_Descr = str(Send_Jobs_List_Row[0])
Job_Date = str(Send_Jobs_List_Row[1])
Job_Body = (Job_Date+':'+Job_Descr+'\n')
body = Job_Body
msg.attach(MIMEText(body, 'html'))
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login(fromaddr, "password")
text = msg.as_string()
server.sendmail(fromaddr, toaddr, text)
server.quit()