如图,收到邮件之后,附件标题不是我设置的,而且后缀名变成了bin,应该是xls
代码片段:
file = MIMEText(open(filepath,'rb').read(),'xls','gb2312') file["Content-Type"] = 'application/octet-stream' file["Content-Disposition"] = 'attachment;filename=%s' % filename #这我也不知道干啥的 file.add_header('Content-1','%s' % filename) msg.attach(file)
也测试了MIMEBase,结果是一样的...
相关分类