Attachments Property (CDONTS Message Object)
Attachments Property (CDONTS Message Object)
The Attachments property returns a single Attachment object or an Attachments collection object. Read-only.
Syntax
Set
collAttachments
=
objMessage.
Attachments
Set
objAttach = objMessage.
Attachments(
index
)
collAttachments
Object. An Attachments collection object.
objMessage
Object. The Message object.
objAttach
Object. A single Attachment object.
index
Long. Specifies the number of the attachment within the Attachments collection. Ranges from 1 to the value specified by the Attachments collection's Count property.
Data Type
Object (Attachment or Attachments collection)
Remarks
You can change individual Attachment objects within the Attachments collection, Add them to the collection, and Delete them from the collection.
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 CDO for NTS Library does not permit any modifications to messages in the Inbox, other than deleting the entire message. Prohibited modifications include adding, deleting, or modifying any attachment; adding, deleting, or modifying any recipient; and modifying any message property, even one with read/write access.
Example
This code fragment uses the Attachments property to retrieve an attachment of the message:
Set collAttachments = objMessage.Attachments
If collAttachments Is Nothing Then
MsgBox "Unable to set Attachments collection"
Exit Function
Else
MsgBox "Attachments count for this message: " & collAttachments.Count
iAttachCollIndex = 0 ' reset global index variable
End If
' from the sample function Attachments_FirstItem
iAttachCollIndex = 1
Set objAttach = collAttachments.Item(iAttachCollIndex)