as shown in the figure, after receiving the email, the attachment title is not set by me, and the suffix name is changed to xls
Code snippet:
file = MIMEText(open(filepath,"rb").read(),"xls","gb2312")
file["Content-Type"] = "application/octet-stream"
file["Content-Disposition"] = "attachment;filename=%s" % filename
-sharp
file.add_header("Content-1","%s" % filename)
msg.attach(file)
also tested that the MIMEBase, result is the same.