问题描述
我在Python中使用win32com.client发送电子邮件。
I am using win32com.client in Python to send an email.
然而,我希望电子邮件的正文成为一个表格(HTML格式的表格)我可以先在Excel中执行,然后复制并粘贴(但如何?),或直接编辑相应的熊猫数据框。
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
这是一个熊猫数据帧不起作用。
newMail.body = my_table
which is a Pandas data frame didn't work.
所以我想知道有没有更聪明的方法来将Excel与Outlook应用程序结合在Python中?
So I'm wondering if there is smarter ways for example, to combine Excel with Outlook apps within Python?
cheers,
推荐答案
有关如何将Excel表转换为HTML的解决方案:,然后你
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.
每个请求中的评论:
一旦你有您的表格的HTML格式版本称为 mytable.html
,您可以将其放入电子邮件中: newMail.body = open( mytable.html)。read()
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()
这篇关于通过Python将Excel剪辑粘贴到电子邮件的正文中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!