Binding to Items in the Exchange Store
Topic Last Modified: 2006-06-12
The Microsoft® ActiveX® Data Objects (ADO) Record object uses only one method to bind items in an Exchange store: the _Record.Open method. This method is used not only to bind to existing items, but also to create new items. You control the behavior of the Open method, such as whether to create a new item or overwrite an existing item, by using various parameters of the method. For example, to open and bind an item for both read and write access, you specify the adModeReadWrite flag in the third parameter. To force the creation of a new item, you specify the adCreateCollection or adCreateNonCollection option in the fourth parameter; adCreateCollection creates a folder item (a collection of other items) and adCreateNonCollection creates a file (non-collection).
Collaboration Data Objects (CDO) objects bind directly to items in the Exchange store by using IDataSource Interface Open Method, SaveTo Method, and SaveToContainer Method. Both the Open Method and the SaveTo Method are similar to the ADO Open method except that with CDO objects, the initial direction of data flow is defined as part of the method. The Open Method first copies data from the item into the object, and the SaveTo Method saves the data in the object to the item. In both cases, when the operation completes, the CDO object is bound to the item in the store. The SaveToContainer Method is just a variation of the SaveTo Method, which frees the caller from having to invent a unique name for the item in the folder.
When using ADO, you get an item's associated stream by requesting the adDefaultStream (-1) property from the object's Fields collection. When using CDO, the method is different: the CDO IItem Interface and the IMessage Interface define the GetStream Method that returns the item's stream directly.