问题
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,
回答1:
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()
来源:https://stackoverflow.com/questions/24028115/paste-excel-clip-to-body-of-an-email-through-python