我已經編寫了一個簡單的Python腳本,它使用MIMEMultipart和SMTPLib向收件人數組發送郵件。 代碼看起來是這樣的:Python郵件在Outlook中放置未佔用空間主題行
import smtplib
import sys
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
sender='[email protected]'
recipients='[email protected]'
subject='A pretty long subject line which looks like this'
mail_server='microsfot_exchange_server_ip'
msg = MIMEMultipart('alternative')
body='Body of the Email'
msg['Subject'] = subject
msg['from'] = sender
msg['to'] = ", ".join(recipients)
s = smtplib.SMTP(mail_server)
s.sendmail(sender, recipients, msg.as_string())
s.quit()
這成功地發送了一封郵件,但像在Outlook郵件客戶端的主題看起來是這樣的:
A pretty long subject line which looks like this
如果您可以包含由Python創建的消息(msg.as_string()'的輸出)和客戶端接收的電子郵件(Outlook))的相關頭文件將很有幫助。 – 2014-09-04 17:34:31
另請參見:您正在使用哪種Python版本? – 2014-09-04 17:48:21
這裏是什麼樣子的標題: '主題:一個相當長的主題行看起來 \t像this' 我使用Python 2.7 – screwgoth 2014-09-04 18:08:29