ADO
ADO
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
The Microsoft® ActiveX® Data Objects (ADO) 2.5 object model is simple in design and has only a few objects. The following sections are a summary of the ADO objects most commonly used to access the Exchange store.
Connection
Use the ADO Connection object to bind to a particular public or private store, handle transactions, and share across Record and Recordset objects to avoid continually rebinding to stores. For example:
Dim Conn as New ADODB.Connection Conn.Provider = "ExOLEDB.DataSource" Conn.Open RootFolderURL Conn.BeginTrans Rec.Open ItemURL, Conn, adModeReadWrite ' .. Conn.CommitTrans ' .. Conn.Close Rec.Close Set Conn = Nothing Set Rec = NothingPlacing Connection object references in ASP Session or Application objects and reusing this connection from one ASP page to another is ideal for optimal server-side performance.
You need a separate Connection object to bind to items in a different Exchange store mailbox store or public store. To avoid poor performance, you should reuse these Connection objects whenever possible. For example:
Dim Conn1 as New ADODB.Connection Dim Conn2 as New ADODB.Connection Dim Rec as New Record ' Assume /vroot1 is mapped to one public store and ' /vroot2 is mapped to another. Conn1.Provider="exoledb.datasource" Conn1.Open "https://servername/vroot1" Conn2.Provider="exoledb.datasource" Conn2.Open "https://servername/vroot2" Rec.Open "https://servername/vroot1/folder1/item.eml", Conn1, adModeReadWrite Rec.Close '... Rec.Open "https://servername/vroot_2/folder2/item2.eml", Conn2, adModeReadWrite
'... Conn1.Close Conn2.Close Rec.Close Set Conn1 = Nothing Set Conn2 = Nothing Set Rec = Nothing
Fields/Field
Use the ADO Fields collection and the ADO Field object to access an item's properties. For example:
Dim Rec as New ADODB.Record Dim Conn as New ADODB.Connection Dim Flds as ADODB.Fields Dim Fld as ADODB.Field Dim Url As StringUrl = "https://server/public/test/item.eml"
Conn.Provider = "ExOLEDB.DataSource" Conn.Open Url
Rec.Open Url, Conn, adModeReadWrite Set Flds = Rec.Fields For Each Fld in Flds '... Next Fld ' ... Conn.Close Rec.Close Set Conn = Nothing Set Rec = Nothing
Record
Use the Record object to access any item in the Exchange store. You have full access to the item's set of properties and its associated stream. For example:
Dim Rec As New ADODB.Record Dim Conn as New ADODB.Connection Dim Stm as ADODB.Stream Conn.Provider = "ExOLEDB.DataSource" Conn.Open "https://server/folder" Rec.Open "https://server/folder/item.txt", Conn Set Stm = Rec.Fields(adDefaultStream).Value '... Conn.Close Rec.Close Set Conn = Nothing Set Rec = Nothing
Recordset
Use the Recordset object to issue Structured Query Language (SQL) SELECT commands in folders. For example:
Dim Conn as New ADODB.Connection Dim Rs as New ADODB.Recordset Conn.Provider = "ExOLEDB.DataSource" Conn.Open RootFolderURLSet Rs.ActiveConnection = Conn "select ""DAV:displayname"" " _ & "from scope('shallow traversal of ""URL""')" _ & "Where ""DAV:ishidden"" = False"
'... Conn.Close Rs.Close Set Conn = Nothing Set Rs = Nothing
Stream
Use the ADO Stream object to access an item's stream. For example:
Dim Stm As ADODB.Stream Dim Rec as New ADODB.Record Dim Conn as New ADODB.Connection Dim Stm2 as New ADODB.Stream Dim Url As StringUrl = "https://server/public/item.txt"
Conn.Provider = "ExOLEDB.DataSource" Conn.Open Url Rec.Open Url, Conn Set Stm = Rec.Fields(adDefaultStream).Value ' Or, alternately Stm2.Open Rec, adModeRead, adOpenStreamFromRecord
'... Conn.Close Rec.Close Stm.Close Stm2.Close Set Conn = Nothing Set Rec = Nothing Set Stm = Nothing Set Stm2 = Nothing
Each of the following Collaboration Data Objects (CDO) objects provides an ADO Fields collection on its default interface, allowing you to access Exchange store item properties directly, as if the object was an ADO Record or Recordset object:
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.