Python:创建邮件-显示邮件但不发送邮件-smtplib+;MimemMultipart+;见解
我目前正在尝试编写一个函数,它将创建一封邮件,然后通过Outlook显示。 这样,用户就可以在Outlook下创建并查看他的新邮件,只需决定是否单击“发送” 我很难找到smtplib的属性,或者像smtplib.display()或 我已经成功地使用smtplib创建并自动发送邮件。我在web上找不到的是显示板条箱邮件的属性 我所拥有的:Python:创建邮件-显示邮件但不发送邮件-smtplib+;MimemMultipart+;见解,python,email,display,smtplib,Python,Email,Display,Smtplib,我目前正在尝试编写一个函数,它将创建一封邮件,然后通过Outlook显示。 这样,用户就可以在Outlook下创建并查看他的新邮件,只需决定是否单击“发送” 我很难找到smtplib的属性,或者像smtplib.display()或 我已经成功地使用smtplib创建并自动发送邮件。我在web上找不到的是显示板条箱邮件的属性 我所拥有的: def createEmailConfirmation(): email_content = """\ <!DOCTYPE
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
def createEmailConfirmation():
电子邮件_content=“”\
标题
确认书
"""
msg=MIMEMultipart('alternative')
msg=email.message.message()
msg['Subject']=“确认邮件”
toaddr=['useraddressmail@test.com']
密件抄送=['']
cc=['']
fromaddr=''其他_useraddressmail@test.com'
toaddrs=toaddr+cc+bcc
password=“password”
msg.add_标题('Content-Type','text/html')
msg.set\u有效负载(电子邮件内容)
s=smtplib.SMTP('**.*.*.*.**')
s、 设置_debuglevel(False)#显示与服务器的通信
msg.display
我觉得这很简单,只适合一行,但我找不到
致以最诚挚的问候,嗨,检查嗨,谢谢你的回复,我看到了这篇文章,但它使用了库“将win32 com.client作为win32导入”,我没有。如果可能的话,我更愿意使用SMTP或MIMEmultipart。但我不知道它是否存在..请检查此答案以安装win32com
https://stackoverflow.com/q/23864234/8150371
。
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