Platform SDK: Exchange 2000 Server

Opening a Recordset

[This is preliminary documentation and subject to change.]

Opening an ADO Recordset object is required for obtaining a list of folder items. This example opens an ADO Record object of a folder, and then opens a recordset based on a Web Store SQL query on the folder. As a test, it outputs all the DAV:displayname values in alphabetical order.

[VBScript]
Dim Rec
Dim Rs
Dim strURL
Dim strQ

Dim DomainName
Dim strLocalPath

'specify your own domain
DomainName = "microsoft.com"
'specify a URL to folder or item
strLocalPath = "public folders/reports/sales"

Set Rec = CreateObject("ADODB.Record")
Set Rs = CreateObject("ADODB.Recordset")

'this URL is for a public folder
strURL = "file://./backofficestorage/" & DomainName & "/" & strLocalPath

Rec.Open strURL

'Construct the SQL query to run on the folder --
'To avoid confusion in escaping quotes,
'Chr(34)'s are used to delimit the URL

strQ = "select "
strQ = strQ & " ""urn:schemas:mailheader:content-class"" "
strQ = strQ & ", ""DAV:href"" "
strQ = strQ & ", ""DAV:displayname"" "
strQ = strQ & " from scope ('shallow traversal of "
strQ = strQ & Chr(34) & strURL & Chr(34) & "')"
strQ = strQ & " ORDER BY ""DAV:displayname"" "

Rs.Open strQ, Rec.ActiveConnection

Rs.MoveFirst

While Not Rs.EOF

   Response.Write Rs.Fields("DAV:displayname").Value & "</br>"
   Rs.MoveNext

Wend


Rs.Close
Rec.Close

[Visual Basic]
Dim Rec As New ADODB.Record
Dim Rs As New ADODB.Recordset
Dim strURL As String
Dim strQ As String

Dim DomainName
Dim strLocalPath

'specify your own domain
DomainName = "microsoft.com"
'specify a URL to folder or item
strLocalPath = "public folders/projects/documentation"

'this URL is for a public folder
strURL = "file://./backofficestorage/" & DomainName & "/" & strLocalPath

Rec.Open strURL

'Construct the SQL query to run on the folder --
'To avoid confusion in escaping quotes,
'Chr(34)'s are used to delimit the URL

strQ = "select "
strQ = strQ & " ""urn:schemas:mailheader:content-class"" "
strQ = strQ & ", ""DAV:href"" "
strQ = strQ & ", ""DAV:displayname"" "
strQ = strQ & " from scope ('shallow traversal of "
strQ = strQ & Chr(34) & strURL & Chr(34) & "')"
strQ = strQ & " ORDER BY ""DAV:displayname"" "
    
Rs.Open strQ, Rec.ActiveConnection
    
Rs.MoveFirst

While Not Rs.EOF

    Debug.Print Rs.Fields("DAV:displayname").Value
    Rs.MoveNext

Wend


Rs.Close
Rec.Close