def as_mailobj(self):
# Create the root message and fill in the from, to, and subject headers
msgRoot = MIMEMultipart('related')
msgRoot['Subject'] = self.subject
msgRoot['From'] = self.get_sender()
msgRoot['To'] = ", ".join(self.recipients)
msgRoot.preamble = 'Generated by mailprod python tool'
for i in range(len(self.headers)):
name, value, params = self.headers[i]
msgRoot.add_header(name, value, **params)
for i in range(len(self.body)):
part = self.body[i]
msgRoot.attach(part)
for i in range(len(self.attachments)):
attachment = self.attachments[i]
msgRoot.attach(attachment)
return msgRoot
评论列表
文章目录