我正在尝试使用Python 3.4回复电子邮件.电子邮件的收件人将使用Outlook(不幸的是),Outlook识别回复并正确显示该线程非常重要.
我目前的代码是:
def send_mail_multi(headers, text, msgHtml="", orig=None):
"""
"""
msg = MIMEMultipart('mixed')
# Create message container - the correct MIME type is multipart/alternative.
body = MIMEMultipart('alternative')
for k,v in headers.items():
if isinstance(v, list):
v = ', '.join(v)
msg.add_header(k, v)
# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
body.attach(MIMEText(text, 'plain'))
if msgHtml != "": body.attach(MIMEText(msgHtml, 'html'))
msg.attach(body)
if orig …Run Code Online (Sandbox Code Playgroud)