邮件发送可以参考文章pyqt5+stmp邮件批量发送不同附件给不同人
经过邮件测试发现,foxmail、QQ收取邮件时,附件均为正常,但是有些客户使用outlook收取邮件时显示不正常,如下图,应该为pdf格式

经查明,发现附件为中文命令时使用,outlook均使用异常,显示格式问题,
isExistAttach = DictData['payload']
if isExistAttach:
filename = os.path.basename(isExistAttach)
att1 = MIMEText(open(isExistAttach,'rb').read(),'base64','utf-8')# 添加表格为附件'gb2312')
att1["Content-Type"] ='application/octet-stream'
# 附件名称为中文时的写法
att1.add_header("Content-Disposition","attachment",filename=('gb2312','', filename))#filename=filename)
msg.attach(att1)
或者
with open(sqlFilePath,'rb')as f:
part = MIMEApplication(f.read())
part.add_header('Content-Disposition','attachment',
filename=Header(fundname,'utf-8').encode())
msg.attach(part)
当使用模块email.header中make_header时即可摆脱中文名问题
isExistAttach = DictData['fileName']
if isExistAttach:
filename = os.path.basename(isExistAttach)
att1 = MIMEText(open(isExistAttach,'rb').read(),'base64','UTF-8')
att1["Content-Type"] ='application/octet-stream;name="%s"' % make_header([(filename,'UTF-8')]).encode(
'UTF-8')
att1["Content-Disposition"] ='attachment;filename= "%s"' % make_header([(filename,'UTF-8')]).encode(
'UTF-8')
msg.attach(att1)
收取多附件正常,outlook文件格式正确