首页 > 解决方案 > 在电子邮件介绍后插入屏幕截图

问题描述

我正在使用下面的代码,它基本上是截取用户表单并将其粘贴到 Outlook 应用程序中。宏工作正常。

我想要实现的是放置一封电子邮件介绍,然后粘贴屏幕截图,但我无法正确执行此操作,因为屏幕截图没有放在文本之后。

这是我的代码

Sub Screenshotemail()

    Dim doc                   As Object, rng As Range

    Application.SendKeys "(%{1068})"
    DoEvents

    'ActiveSheet.Paste
    With CreateObject("Outlook.Application").CreateItem(0)
         Set doc = .GetInspector.WordEditor
         doc.Range(0, 0).Paste
        .display
        .To = ""
        .CC = ""
        .Body = "Dear All, " & Chr(10) & Chr(10) & "I kindly remind you that forecasts for program " & Chr(10) & Chr(10) _
         & "Please enter your forecast at the link below." _
         & Chr(10) & Chr(10) & lien & Chr(10) & Chr(10) & "Best Regards,"
        .Subject = "Test:"
        .Importance = olImportanceHigh
    End With

End Sub

有没有办法让它工作?

标签: vbaoutlook

解决方案


我的朋友,这需要我几个小时,但我想它有效

只需使用 htmlbody 代替 body,然后在您的消息后连接 htmlbody

参考 在 Outlook 中粘贴表之前写入 - Excel VBA

子截图email()

Dim doc As Object, rng As Range
Dim wdDoc As Object
Dim wdRange As Range

Application.SendKeys "(%{1068})"
DoEvents
Set wdDoc = CreateObject("Word.Application")
'ActiveSheet.Paste
With CreateObject("Outlook.Application").CreateItem(0)
    Set doc = .GetInspector.WordEditor
    doc.Range(0, 0).Paste
    .display
    .To = ""
    .CC = ""
    .htmlbody = "Dear All, " & Chr(10) & Chr(10) & "I kindly remind you that forecasts for program " & Chr(10) & Chr(10) _
     & "Please enter your forecast at the link below." _
     & Chr(10) & Chr(10) & lien & Chr(10) & Chr(10) & "Best Regards," & .htmlbody
    .Subject = "Test:"
    .Importance = olImportanceHigh
End With

结束子


推荐阅读