嵌入附件时保存附件时出错 [英] Error saving attachments when they are embedded
问题描述
我要保存Outlook附件(作为副本的一部分).
I'm saving Outlook attachments (as part of a copy).
当附件是嵌入式图像时,我从 objAtt.SaveAsFile strFile
行收到一条错误消息.
I get an error message from the line objAtt.SaveAsFile strFile
when the attachment is an embedded image.
(感激地复制了!)代码是:
The code (gratefully copied!) is:
Sub CopyAttachments(objSourceItem, objTargetItem)
Dim objAtt As Outlook.Attachment
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , 1, objAtt.DisplayName
fso.DeleteFile strFile
Next
Set fldTemp = Nothing
Set fso = Nothing
End Sub
完整的错误消息是:
我不需要嵌入式图像,因此跳过它们也可以.
I don't need embedded images, so skipping them would work too.
推荐答案
这是RTF消息吗?RTF消息不是将图像和对象(例如Excel电子表格)作为文件而是作为OLE对象嵌入图像,而 Attachment.SaveAsFile
对于OLE附件将失败.如果要这样过滤掉附件,请确保使用 Attachment.Type = olOLE(6)
跳过附件,或者仅处理 olByValue
类型的附件,或者 olEmbeddeditem
.
Is that an RTF message? RTF messages embed images and objects (such as Excel spreadsheets) not as files, but as OLE objects, and Attachment.SaveAsFile
will fail for the OLE attachments. If you want to filter out attachments like that, make sure you either skip attachments with the Attachment.Type = olOLE (6)
or only deal with the attachments of type olByValue
or olEmbeddeditem
.
如果您仍然需要保存OLE附件,则可以使用兑换-其 RDOAttachment . SaveAsFile
方法将从大多数常见的OLE附件中提取文件数据(例如Word文档,PDF文件,Excel电子表格,图像等).
If you still need to save OLE attachments, you can use Redemption - its RDOAttachment.SaveAsFile
method will extract the file data from most common OLE attachments (such Word docs, PDF files, Excel spreadsheets, images, etc.)
这篇关于嵌入附件时保存附件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!