我目前正在尝试编写一个函数,该函数将创建一个邮件,然后通过Outlook显示它。 像这样,用户可以在Outlook下创建和查看他的新邮件,然后决定点击发送。
我很难找到smtplib的属性,或Mimemultipart的属性,如 smtplib.display ()或
msg = MIMEMultipart('alternative')
msg = email.message.Message()
msg.display(True).
我已经成功创建并使用smtplib自动发送邮件。我在网上找不到的是这个属性来显示包装邮件......
我有什么:
def createEmailConfirmation():
email_content = """\
<!DOCTYPE html><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div class="table-responsive">
<table class="table table-bordered m-b-0">
<thead>
<tr>
<th> Title </th>
</tr>
</thead>
<tbody>
<tr>
<td> Confirmation </td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
"""
msg = MIMEMultipart('alternative')
msg = email.message.Message()
msg['Subject'] = 'Confirmation Mail'
toaddr = ['useraddressmail@test.com']
bcc = ['']
cc = ['']
fromaddr = ''other_useraddressmail@test.com'
toaddrs = toaddr + cc + bcc
password = "password"
msg.add_header('Content-Type', 'text/html')
msg.set_payload(email_content)
s = smtplib.SMTP('**.***.**.**')
s.set_debuglevel(False) # show communication with the server
msg.display
我觉得这很简单,只适合一行,但我找不到......
最诚挚的问候,