我想编写一个简单的python脚本,尽管从smtp服务器作为电子邮件发送给给定的电子邮件列表,也可以将从Outlook导出的EML文件发送出去.我知道如何发送简单的电子邮件,但是以电子邮件的形式发送EML文件不是我能做的事,无法在Google上找到它.谁能帮助我. EML文件实际上是带有嵌入式图像的HTML格式.也欢迎任何其他建议.
解决方法:
在email module example上构建,尝试将MIME附件与HTML内容一起使用.
如果EML格式只是HTML,则应该可以使用.
该示例显示了如何构造带有(html)附件的消息:
# Create the body of the message (a plain-text and an HTML version).
text = "Hi!\nHow are you?\nHere is the link you wanted:\nhttp://www.python.org"
html = """\
Hi!
How are you?
Here is the link you wanted.
"""
# Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
# 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.
msg.attach(part1)
msg.attach(part2)
#...
标签:email,linux,python