python邮件正文表格怎么编辑_通过Python将Excel剪辑粘贴到电子邮件的正文中

I am using win32com.client in Python to send an email.

However I want the body of the email to be a table (HTML- formatted table), I can do it in an Excel first and then copy and paste (but how?), or directly edit the corresponding Pandas data frame.

newMail.body = my_table which is a Pandas data frame didn't work.

So I'm wondering if there is smarter ways for example, to combine Excel with Outlook apps within Python?

Cheers,

解决方案

There are solutions regarding how to convert your Excel table to HTML here: How do I save Excel Sheet as HTML in Python?, and then you just drop the HTML into the body of your email.

Per request in the comments:

Once you have the HTML-formatted version of your table in a file called mytable.html, you can drop it into the email with: newMail.body = open("mytable.html").read()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值