【问题标题】:Insert Python Objects when sending email using Outlook使用 Outlook 发送电子邮件时插入 Python 对象
【发布时间】:2017-12-07 03:44:01
【问题描述】:

如题的简单问题:如何将 Python 对象(如刚生成的 matplotlib 图形对象,未保存到硬盘中)插入或复制到 Outlook 发送的电子邮件中?

我没有使用 SMTP 模块,而是通过 win32com.client 操作 Outlook。目前部分代码如下:

import matplotlib.pyplot as plt
import win32com.client
import matplotlib.gridspec as gridspec

fig = plt.figure(figsize = (20,30))
gs = gridspec.GridSpec(5,2)

ax = plt.subplot(gs[0,0])
ax.plot(range(10))

obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "Daily Report of Volatility"
newMail.HTMLBody = "<h1> \
                        This is a test \
                    </h1> \
                    <p> \
                        I am a email-robot \
                    </p> \
                    "

newMail.To = "Kyle"

newMail.display()

只想将 'fig' 对象插入邮件正文。

将欣赏任何插图!非常感谢!

【问题讨论】:

标签: python email matplotlib outlook


【解决方案1】:

您需要生成图像,然后添加对消息正文的引用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    • 2011-09-14
    • 2013-08-16
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    相关资源
    最近更新 更多