python发送带表格的邮件_python中如何将表格式的pandas数据帧发送到邮件中

我试图通过邮件发送熊猫数据帧。我试过了,但没能弄到。我的代码是

编码import pandas as pd

import json

import requests

from requests.auth import HTTPBasicAuth

import datetime

import smtplib

from email.mime.multipart import MIMEMultipart

from email.mime.text import MIMEText

import pdb

ticket_details=pd.DataFrame(list_values,

columns['incident',"short_description","priority","assignment_group"])

#converting a datframe into html table

df=ticket_details.to_html()

send ="xxx@xxx.com"

reciever="xxx@xxx.com"

subject="incident details "

msg = MIMEMultipart('alternative')

msg['From'] = send

msg['To'] = reciever

msg['Subject'] =subject

html_body = str(df)

messagePlain = 'Look at the incident details'

msg.attach(MIMEText(messagePlain, 'plain'))

msg.attach(MIMEText(html_body, 'html')

server = smtplib.SMTP("xxx.com")

server.sendmail(send, reciever, msg.as_string())

server.quit()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值