我正在使用此代码发送我通过 Outlook 电子邮件地址(与我的地址不同的另一个地址电子邮件)创建的数据帧(表格格式)的结果,这是一种推送通知电子邮件,代码完美地返回了我的内容我正在寻找(电子邮件中的表格格式),但问题是我有 3 个不同的数据框。每次我发送电子邮件通知程序时,它只使用电子邮件结果中的第一个数据帧,其他 2 个数据帧将在附件 html 中创建,不会在电子邮件结果中看到。这是我应该更改的代码:
import smtplib
import sys
# Log in to email account.
smtpObj = smtplib.SMTP('smtp-mail.outlook.com', 587)
smtpObj.ehlo()
smtpObj.starttls()
smtpObj.login( 'sender@outlook.com',password)
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from smtplib import SMTP
import smtplib
recipients = ['receiver@outlook.com']
msg = MIMEMultipart()
msg['Subject'] = "Push Notifier"
msg['From'] = 'sender@outlook.com'
import sys
html = """This is an automatic email to inform you that you have wrong data in your dataframe1\
<html>
<head></head>
<body>
{0}
</body>
</html>
""".format(dataframe1.to_html())
part1 = MIMEText(html, 'html')
msg.attach(part1)
smtpObj.sendmail(msg['From'], recipients , msg.as_string())
html = """This is an automatic email to inform you that you have wrong data in your dataframe2\
<html>
<head></head>
<body>
{0}
</body>
</html>
""".format(dataframe2.to_html())
part1 = MIMEText(html, 'html')
msg.attach(part1)
smtpObj.sendmail(msg['From'], recipients , msg.as_string())