如何将表格格式的熊猫数据框发送到python而不是附件中的邮件正文

时间:2019-06-28 16:12:25

标签: python pandas

我正在尝试通过邮件发送熊猫数据框。我尝试过,但是给了我html文件,我希望将数据框显示在邮件正文中

  

请参见我下面的代码

        send ="hiro-alert@one.com"

        reciever="vishal.suryavanshi@see.com"
        subject="incident details "


        msg = MIMEMultipart()
        msg['From'] = send
        msg['To'] = reciever 
        msg['Subject'] =subject


        html = """\
        <html>
        <head></head>
          <body>
             {0}
          </body>
        </html>""".format(ticket_details.to_html())




        messagePlain = 'Look at the incident details'

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

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



        server = smtplib.SMTP("mailrelay.nisource.net")
        #pdb.set_trace()
        #print ("excuse me")

        #pdb.set_trace()
        #print ("hello")
        #pdb.set_trace()

        server.sendmail(send,reciever , msg.as_string())
        #pdb.set_trace()
        server.quit()
  

我希望我的数据框以表格格式显示在邮件正文中

0 个答案:

没有答案