我正在使用pd.to\ html格式对于通过电子邮件发送我的熊猫数据帧,电子邮件在Gmail浏览器中打开良好,所有表格都在电子邮件正文中。但它们不是在Outlook中打开的,所有的表都是作为一个HTML附件在Outlook中打开的。你知道吗
使用以下代码将我的数据帧转换为HTML。你知道吗
df_1=df_1.to_html(index=False,header=True,border=4,justify=left,col_space=9)
来自IPython.core.display文件导入显示,HTML 显示(HTML(数据框1))
这就是我发送邮件的方式电子邮件:你知道吗
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
email_user = 'xyz@x.com'
email_password = '*********'
email_send = 'xyz@x.com'
subject = 'ABCDEF'
msg = MIMEMultipart()
msg['From'] = email_user
msg['To'] = email_send
msg['Subject'] = subject
body_1 = """ Hey All,
Please find the data:
"""
msg.attach(MIMEText(body_1,'plain'))
msg.attach(MIMEText(df_1,'html'))
text = msg.as_string()
server = smtplib.SMTP('smtp.gmail.com',587)
server.starttls()
server.login(email_user,email_password)
server.sendmail(email_user,email_send.split(','),text)
server.quit()
没有错误的电子邮件是在Gmail正常打开。但在outlook中,表是作为附件出现的。你知道吗
你可以制作一个附件作为html。那个为我工作。你知道吗
相关问题 更多 >
编程相关推荐