[英][Python]Why are email pdf attachments not showing up on Outlook/Thunderbird, while they do on Gmail? (Sent from a Python environment)
[英]Python-sent MIME email attachments not showing up in mail.live
我有一個Python 3腳本,該腳本使用MIMEMultipart發送帶有已生成附件的.xlsx文件的電子郵件。 我曾經在Py2上使用相同的腳本來發送相同的生成文件,唯一的區別是Py2腳本從MySQL收集了信息以創建.xlsx,而Py3腳本使用了PostgreSQL。
msg = MIMEMultipart('alternative')
msg.attach(MIMEText("""HTML stuff""", 'html'))
with open(analysis_file, "rb") as fil:
msg.attach(MIMEApplication(
fil.read(),
Content_Disposition='attachment; filename="%s"' % os.path.basename(analysis_file),
Name=os.path.basename(analysis_file)
))
msg['Subject'] = "SUBJECT"
msg['From']="Me <me@me.com>"
msg['To']= "You <you@you.com>"
server.sendmail(FROMADDR, ["you@you.com"], msg.as_string())
但是,當我切換到腳本的Py3版本時,附件停止出現在Microsoft的mail.live中。 仍在顯示帶有郵件附件的回形針符號,但找不到。
- 編輯:
如果我設置了自動轉發到Gmail帳戶,則.xlsx附件會正常顯示在該帳戶中; 但是,如果我手動轉發,則不會。
改變中
msg = MIMEMultipart('alternative')
至
msg = MIMEMultipart('html')
修復。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.