Platform SDK: CDO 1.2.1 |
The Item property returns a single Attachment object from the Attachments collection. Read-only.
objAttachColl.Item(index)
objAttachColl.Item(recordKey)
The Item property is the default property of an Attachments collection, meaning that objAttachColl(index) is syntactically equivalent to objAttachColl.Item(index) in Microsoft® Visual Basic® code.
Object (Attachment)
The Item property works like an accessor property for small collections.
The Item(index) syntax selects an arbitrary Attachment object within the Attachments collection.
The Item(recordKey) syntax returns the first Attachment object with a MAPI record key equivalent to the string specified by recordKey. You can obtain the MAPI record key of an attachment through its Fields collection, but you cannot convert it programmatically to the requisite string format with Visual Basic. The record key is in a counted binary format for which Visual Basic and CDO have no corresponding data type.
The recordKey parameter corresponds to the MAPI property PR_RECORD_KEY, converted to a string of hexadecimal characters.
Although the Item property itself is read-only, the Attachment object it returns can be accessed in the normal manner, and its properties retain their respective read/write or read-only accessibility.
This code fragment shows the Count and Item properties working together to traverse the collection:
' from Util_SmallCollectionCount(objAttachColl As Object) Dim strItemName(100) as String Dim i As Integer ' loop counter ' error handling omitted from this fragment ... For i = 1 To objAttachColl.Count Step 1 strItemName(i) = objAttachColl.Item(i).Name ' or = objAttachColl(i) since Item and Name are default properties If 100 = i Then ' max size of string array Exit Function End If Next i