I\'m saving Outlook attachments (as part of a copy).
I get an error message from the line objAtt.SaveAsFile strFile
when the attachment is an embedded image
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
.
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.)