Platform SDK: CDO 1.2.1 |
The Attachments property returns a single Attachment object or an Attachments collection object. Read-only.
Set objAttachColl = objMessage.Attachments
Set objOneAttach = objMessage.Attachments(index)
Object (Attachment or Attachments collection)
You can change individual Attachment objects within the Attachments collection, Add them to the collection, and Delete them from the collection. However, unlike the Recipients property, the Attachments property is read-only, so you cannot, for example, copy the complete Attachments collection to another message with a single instruction.
Although the Attachments property itself is read-only, the collection it returns can be accessed in the normal manner through its Add and Delete methods, and the properties on its member Attachment objects retain their respective read/write or read-only accessibility.
The Attachments property does not correspond to a MAPI property and cannot be rendered into HTML hypertext by the CDO Rendering Library. If a single Attachment object is returned, it could be rendered as an object by setting the ObjectRenderer object's DataSource property to the Attachment object returned by the Attachments property.
This code fragment uses the Attachments property to retrieve an attachment of the message:
' from the sample function Message_Attachments Set objAttachColl = objOneMsg.Attachments If objAttachColl Is Nothing Then MsgBox "unable to set Attachments collection" Exit Function Else MsgBox "Attachments count for this msg: " & objAttachColl.Count iAttachCollIndex = 0 ' reset global index variable End If ' from the sample function Attachments_FirstItem iAttachCollIndex = 1 Set objAttach = objAttachColl.Item(iAttachCollIndex)