我需要添加多个附件以通过 python 脚本自动发送电子邮件..
我是 python 脚本的新手。所以请帮忙。提前致谢..
下面是代码片段。
请让我知道我必须对以下代码进行哪些更改。
themsg = MIMEMultipart()
themsg['Subject'] = Subject
themsg['To'] =','.join(Email_ID)
themsg['From'] =email_from
themsg.preamble = 'I am not using a MIME-aware mail reader.\n'
msg = MIMEBase('application', 'zip')
msg.set_payload(zf_csv.read())
zf_csv.close()
msg.set_payload(zf_pdf.read())
zf_pdf.close()
Encoders.encode_base64(msg)
print 'csv attachment is'+str(os.path.basename(current_dirs+csv_to_mail))
print 'pdf attachment is'+str(os.path.basename(current_dirs+pdf_to_mail))
msg.add_header('Content-Disposition', 'attachment; filename="(%s,%s)"' %(os.path.basename(current_dirs+csv_to_mail),os.path.basename(current_dirs+pdf_to_mail))