Messages Collection Object

The Messages collection object contains one or more AppointmentItem, GroupHeader, MeetingItem, and Message objects.

At a Glance

Specified in type library: CDO.DLL
First available in: CDO Library version 1.0.a
Parent objects: Folder
Child objects: AppointmentItem
GroupHeader
MeetingItem
Message
MessageFilter
Default property: Item

A Messages collection is considered a large collection, which means that the Count property has limited validity, and the best way to access an individual GroupHeader or Message object within the collection is to use either its unique identifier or the Get methods. For more information on collections, see Object Collections.

Properties


Name
Available since version
Type

Access
Application 1.0.a String Read-only
Class 1.0.a Long Read-only
Count 1.1 Long Read-only
Filter 1.1 MessageFilter object Read/write
Item 1.1 GroupHeader object or Message object Read-only
Parent 1.0.a Folder object Read-only
RawTable 1.1 IUnknown object Read/write (Note: Not available to Visual Basic applications)
Session 1.0.a Session object Read-only

Methods


Name
Available since version
Parameters
Add 1.0.a (optional) subject as String,
(optional) text as String,
(optional) type as String,
(optional) importance as Long
Delete 1.0.a (none)
GetFirst 1.0.a (optional) filter as String
GetLast 1.0.a (optional) filter as String
GetNext 1.0.a (none)
GetPrevious 1.0.a (none)
Sort 1.0.a (optional) SortOrder as Long,
(optional) PropTag as Long,
(optional) PropID as String

Remarks

A Messages collection can be rendered into HTML hypertext in tabular form using the CDO Rendering ContainerRenderer object. To specify this, set the container renderer's DataSource property to the Messages collection object itself.

With the same DataSource setting, the container renderer's RenderProperty method can also render selected properties of the collection's parent Folder object. The individual properties that can be rendered are indicated in the Folder object property descriptions.

Large collections, such as the Messages collection, cannot always maintain an accurate count of the number of objects in the collection. It is strongly recommended that you use the GetFirst, GetLast, GetNext, and GetPrevious methods to access individual items in the collection. You can access one specific appointment, meeting, or message by using the Session object's GetMessage method, and you can access all the items in the collection with the Visual Basic For Each construction.

The order that items are returned by GetFirst, GetLast, GetNext, and GetPrevious depends on whether they are sorted or not. The AppointmentItem, GroupHeader, MeetingItem, and Message objects within a collection can be sorted on a MAPI property of your choice, either ascending or descending, using the Sort method. When the items are not sorted, you should not rely on these methods to return the items in any specified order. The best programming approach to use with unsorted collections is to assume that the access functions are able to access all items within the collection, but that the order of the objects is not defined.

A message and most of its attachments, fields, properties, and recipients are read from the message store when the application first accesses the Message object. For performance reasons, attachment data and field values greater than 1,000 bytes are read from the store only when the application explicitly accesses the Attachment or Field objects. All other properties of the Attachment and Field objects are read when the parent message is read.

GroupHeader objects are not saved in the message store. They cannot be created or deleted programmatically by your application. They are generated only when a CDO Rendering TableView object is being applied to the Messages collection, and they do not persist when the view is released.