如何将图表或图形插入到Outlook邮件的正文中 [英] How to insert chart or graph into body of Outlook mail

查看:4005
本文介绍了如何将图表或图形插入到Outlook邮件的正文中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有一个关于如何使用VBA将图表插入Outlook电子邮件正文中的问题,该电子邮件正在起草答案,但已经消失了。

There was a question posted here about how to use VBA to insert a chart into the body of an Outlook email that I drafted an answer to but has since disappeared.

我以为没有Sendkeys会做一个比较简单的方法,但是看起来像我错了!

I thought there would be a simpler way to do this without Sendkeys but looks like I was mistaken!

无论如何,我以为我会发布答案,以防原来的海报仍然在寻找,或者有其他人需要它,或者即使有人能想出更好的解决方案。

Anyway, I thought I'd post the answer in case the original poster is still looking, or if anyone else needs it, or even if someone can come up with a better solution.

推荐答案

Sub charttoemail()

Dim myOutlook As Outlook.Application
Dim myMessage As Outlook.MailItem

On Error GoTo Handler
Set myOutlook = GetObject(, "Outlook.Application")
Set myMessage = myOutlook.CreateItem(olMailItem)

'Copy the chart
ActiveChart.ChartArea.Copy

    With myMessage

        .To = "steven@test.com"
        .Subject = "Here's your chart"
        .BodyFormat = olFormatHTML
        .Body = "Hi, Here's your chart" & vbCr & vbCr
        'Display to view the email and send to automatically fire it off
            .Display
            '.Send

    End With

'First key moves cursor to end of email and the second
'pastes the copied chart
SendKeys "^{END}"
SendKeys "^({v})", True

Set myOutlook = Nothing
Set myMessage = Nothing

Exit Sub

'If Outlook is not open, open it
Handler:

Set myOutlook = CreateObject("Outlook.Application")
Err.Clear
Resume Next

End Sub

这篇关于如何将图表或图形插入到Outlook邮件的正文中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆