我可以复制第一封邮件中的所有内容,但签名中的图片除外。这是为什么?此代码是(并且需要)在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
我可以使用this SO question中提到的方法复制所有内容(包括sig。图片),所以我有一个解决方法,但我想知道为什么HTML主体的简单复制/粘贴不起作用,因为我只是复制HTML文本。
答案 0 :(得分:1)
解决方案:
签名图片附加到邮件并隐藏(如使用.Display
时未被视为附加图片)。为了使用图像复制完整签名,我只需要复制所有附件。