【发布时间】:2016-05-08 23:39:56
【问题描述】:
str_htmlHeader = "<!DOCTYPE HTML PUBLIC>\n<html>\n";
str_htmlHeader += "<head>\n\t<title>Audi Cloud Services</title>\n</head>\n\n";
str_htmlHeader += "<body>\n\n<h1>Nightly build test results</h1>\n";
str_htmlFooter = "\n</body>\n\n</html>";
for root, dirnames, filenames in os.walk(r'\\ac-srvfile01\_Embedded\VCon1\proj_customer\337159_Audi_ACR_and_TSSS\pcm-audio'):
for filename in fnmatch.filter(filenames, '*.html'):
reportContent = open(os.path.join(root,filename)).read()
attachment = MIMEText(str_htmlHeader+reportContent+str_htmlFooter, 'html')
msg.attach(attachment)
#msg.attach(MIMEText(open(filename).read(), "text/html"))
我正在将消息发送给相关人员,但电子邮件将通过另一封电子邮件发送给受尊敬的人。我想收集所有报告并将其作为一封电子邮件发送。但上面的代码将报告作为不同的电子邮件发送。有人可以帮我解决这个问题吗?
【问题讨论】:
-
消息格式发送正确。我现在可以发送消息了。但是消息作为单独的电子邮件发送,但我想将其作为单个电子邮件发送。我编辑了我的代码
-
此代码发送一封电子邮件,其中包含一个 HTML 部分。多部分容器无用但无害。目前尚不清楚您希望此消息应包含哪些其他部分,以及您仍未向我们展示的代码中可能发送的其他哪些消息。
-
首先,它读取html消息并将其作为消息发送给相关人员。我想一次收集所有 html 消息或多条消息,然后作为电子邮件发送一次。而不是作为单独的电子邮件发送。我编辑了我的代码。一旦它读取了 html 消息,它就会作为电子邮件发送。但我想阅读几条或全部 html 消息并将其作为一封电子邮件发送
标签: python python-2.7 email concatenation smtplib