嗨,我正在使用以下代码以及Pandas和Numpy
import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = '[email protected]'
mail.Subject = 'Test'
mail.Body = 'Message body'
mail.HTMLBody = '<html>............................</html>'
#this field is optional
# To attach a file to the email (optional):
#attachment = "Path to the attachment"
#mail.Attachments.Add(attachment)
mail.Send()
在html体中我想使用pandas中的一些值,如df.shape [0]或df ['column']。max()或甚至variable1 = df ['column']。max()
我如何在上面的代码中实现这一点,我打算在HTML消息中使用Pandas中的值到Outlook。
电子邮件的正文是一个字符串,因此您只需使用format
并替换任何变量,例如:
mail.HTMLBody = '<html>........variable1 is: {v}....</html>'.format(v=variable1)