除了签名中的图像,我可以复制第一封邮件中的所有内容。这是为什么?此代码是(并且需要)在excel中运行。这是我的问题的一个最小示例,供您测试,从excel运行代码并添加对Microsoft Outlook对象库的引用。使用“ F8”逐步执行代码以查看详细信息。
Option Explicit
Dim objOutlook As Outlook.Application
Dim objOutlookMsgTemplate As Outlook.MailItem
Dim objOutlookMsg2 As Outlook.MailItem
Sub main()
CreateOutlookSession
CopyMailBody
End Sub
Function CreateOutlookSession()
On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set objOutlook = CreateObject("Outlook.Application")
End If
On Error GoTo 0
End Function
Function CopyMailBody()
Set objOutlookMsgTemplate = objOutlook.CreateItem(olMailItem)
Set objOutlookMsg2 = objOutlook.CreateItem(olMailItem)
With objOutlookMsg1
.Display 'this mail has a signature with pictures, if your default sig contains some
.HTMLBody = "signature below" & .HTMLBody
End With
With objOutlookMsg2
.HTMLBody = objOutlookMsgTemplate.HTMLBody 'this copies everything but pictures from my signature.. why?
.Display 'this mail does not contain the image from mail 1, just an area of the same size with a "file not found" message within
End With
End Function
我可以使用此SO问题中提到的方法来复制所有内容(包括签名图片),因此我有一种解决方法,但是我不知道为什么简单地复制/粘贴HTML正文无效,因为我仅复制HTML文本。
解:
签名图片将附加到邮件中并隐藏(如使用时未显示为附加图片.Display
)。为了复制带有图像的完整签名,我只需要复制所有附件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句