Partager via


Listing Contacts Using ADO

Topic Last Modified: 2009-07-27

Example

VBScript

Note

The following example uses a file URL with the Exchange OLE DB (ExOLEDB) provider. The ExOLEDB provider also supports The HTTP: URL Scheme. Using The HTTP: URL Scheme allows both client and server applications to use a single URL scheme.

' Listing Contacts Using ADO

<%@ Language=VBScript %>
<html><body>

<%

Dim Rs
Dim Rec
Dim strURL


' Specify your own domain.
DomainName = "mydomain.contoso.com"

' Specify the URL to a folder or an item.
strLocalPath = "MBX/User1/Contacts"

Set Rec = CreateObject("ADODB.Record")
Set Rs = CreateObject("ADODB.Recordset")
strURL = "file://./backofficestorage/" & DomainName & "/" & strLocalPath

Rec.Open strURL

Set Rs.ActiveConnection = Rec.ActiveConnection


Rs.Source = "SELECT ""DAV:href"", " & _
" ""urn:schemas:contacts:email1"", " & _
" ""urn:schemas:contacts:nickname"", " & _
" ""urn:schemas:contacts:title"" " & _
"FROM scope('shallow traversal of """ & strURL & """') "
Rs.Open

%> <FONT FACE=ARIAL SIZE=2>
<br><br>
<TABLE cellspacing=0 cellpadding=4>
<%

Do Until Rs.EOF
response.write "<tr><td>"

Response.Write "Nickname : " & Rs.Fields("urn:schemas:contacts:nickname").Value
response.write "</td><td>"

Response.Write "Email1 : " & Rs.Fields("urn:schemas:contacts:email1").Value
response.write "</td><td>"

Response.Write "Title : " &Rs.Fields("urn:schemas:contacts:title").Value
response.write "</td><td>"

Rs.MoveNext
Loop

%>
</table>

</body></html>