| Platform SDK: Exchange 2000 Server |
[This is preliminary documentation and subject to change.]
This example expands on the Opening a Recordset example by narrowing the scope of the query to folders. You can select folders by stipulating that the DAV:isfolder property equals TRUE and DAV:ishidden is FALSE in a WHERE clause.
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 = "MBX/User1"
Set Rec = CreateObject("ADODB.Record")
Set Rs = CreateObject("ADODB.Recordset")
'this URL is to a users's mailbox
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 & ", ""DAV:isfolder"" "
strQ = strQ & " from scope ('shallow traversal of "
strQ = strQ & Chr(34) & strURL & Chr(34) & "')"
strQ = strQ & " WHERE ""DAV:isfolder"" = TRUE"
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