Reading File References

Attachment objects with a Type property of CdoFileLink are similar to file attachments, except that the file is not included with the message. Rather, it is stored at the location specified in the Attachment object’s Source property. Because the file is already on disk, there is no need to call the WriteToFile method. In fact, it is an error to do so. If the receiving email client software wishes to manipulate the attachment, it can do so as it would any file. For example, the file could be copied to the local machine like this:

' CdoAttachment already Dim'ed and set.
   
FileCopy CdoAttachment.Source, "C:\My Documents\" & CdoAttachment.Name

When an attachment is a file reference, the full path and filename are specified in UNC format in the Source property of the Attachment object. By convention, the Name property should contain the filename without the path, but this is up to the sender. If you absolutely must have the filename as it currently exists on disk, you must parse the value found in the Source property.

Get CDO & MAPI Programming with Visual Basic: now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.