Platform SDK: CDO 1.2.1

MAPI Functions and the CDO Library

Compared to the function call interfaces of traditional application programming interface (API) libraries, an Automation object library yields faster development and code that is easier to read, debug, and maintain.

The CDO Library also takes care of many programming details for you, such as memory management and keeping count of the number of objects in collections.

The following table compares a traditional function call interface, such as CMC or Simple MAPI, with the CDO Library interface.

Task or code Function call interface CDO Library
Dim mFiles() As MapiFile
Dim mRecips() As MapiRecip
Requires arrays of these structures to be declared, even if the developer does not use them.
Automatically manages these structures as child objects of the parent Message object.
ReDim mRecips(0)
ReDim mFiles(0)
Structures are resized by redimensioning arrays.
Objects are added to collections with the Add method.
mMessage.RecipCount = 1
Requires developer to indicate the number of recipients and attachments.
Automatically determines the number of objects in these collections.
Error handling
Each function call returns its own set of error codes.
Integrated with Visual Basic error handling during both design and run time.
Return values Returned implicitly in the parameters of the function call. Returned as an explicit result of a method or in object properties.

As programming tasks grow more complex, the function call approach becomes increasingly unwieldly. In contrast, the CDO Library expands gracefully to encompass greater complexity. A well-planned, thorough framework of collections, objects, methods, and properties can neatly encompass very complex systems.