【问题标题】:Send a Excel shape by Outlook email通过 Outlook 电子邮件发送 Excel 形状
【发布时间】:2019-03-14 17:24:47
【问题描述】:

我已经编写了此代码,我想通过电子邮件发送 Excel 中已经存在的图像(称为Picture 1810)。但我无法发现如何执行.Body

谁能帮帮我?

Sub CreateMail()    
    Dim objOutlook As Object
    Dim objMail As Object
    Dim rngTo As Range
    Dim rngCC As Range
    Dim rngSubject As Range
    Dim rngBody As Shape
    Dim rngAttach As Range

    Set objOutlook = CreateObject("Outlook.Application")
    Set objMail = objOutlook.CreateItem(0)

    With ActiveSheet
        Set rngTo = .Range("f2")
        Set rngCC = .Range("f3")
        Set rngSubject = .Range("c2")
        Set rngBody = .Shapes("Picture 1810")
    End With

    With objMail
        .To = rngTo.Value
        .CC = rngCC.Value
        .Subject = rngSubject.Value
        .Body = rnbbody
        .Send
    End With

    Set objOutlook = Nothing
    Set objMail = Nothing
    Set rngTo = Nothing
    Set rngSubject = Nothing
    Set rngBody = Nothing
    Set rngAttach = Nothing
End Sub

【问题讨论】:

  • 我不想像图像一样嵌入一系列单元格,我已经有一个图像,我想在电子邮件中设置形状或对象的范围和过去
  • 您必须将形状作为图像导出到文件夹,然后如上述链接所示将其嵌入
  • 要导出形状,您可以将它放在图表对象中并如图所示导出HERE 或使用 Stephen Bullen 的 PastePicture 函数,如图所示 HERE

标签: excel vba email outlook


【解决方案1】:

这样您就可以保留您的标准电子邮件签名并将形状粘贴在正文上方或像中间的字符一样:

With objMail
    .To = rngTo.Value
    .CC = rngCC.Value
    .Subject = rngSubject.Value
    .Display
    Dim wdDoc As Word.Document
    Set wdDoc = .GetInspector.WordEditor
    If Not wdDoc Is Nothing Then
        With wdDoc.Range
            .Collapse wdCollapseStart
            .InsertBefore "Hi there," & vbCrLf & "here's my shape:" & vbCrLf
            .Collapse wdCollapseEnd
            .InsertAfter vbCrLf & "Best wishes," & vbCrLf
            .Collapse wdCollapseStart

            ActiveSheet.Shapes("Picture 1810").Copy
            '.Paste ' over the text
            .PasteAndFormat wdChartPicture ' within text
        End With
        Set wdDoc = Nothing
    End If
    '.Send
End With

【讨论】:

  • 小改动,但效果很好!非常感谢!!
猜你喜欢
  • 2011-09-14
  • 2012-03-03
  • 1970-01-01
  • 2018-07-24
  • 1970-01-01
  • 2016-01-18
  • 2013-11-23
  • 2020-05-30
相关资源
最近更新 更多