Microsoft KB Archive/314180

= How to retrieve all the items in a public folder on a computer that is running Exchange 2000 =

Article ID: 314180

Article Last Modified on 7/21/2004

-

APPLIES TO


 * Microsoft Exchange 2000 Server Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft XML Core Services 4.0
 * Microsoft XML Core Services 4.0

-



This article was previously published under Q314180



SUMMARY
This article describes how to use Microsoft XML 3.0 and Microsoft Visual Basic .NET to retrieve all the items, not including the folders, from a public folder on a computer that is running Microsoft Exchange 2000 Server.



MORE INFORMATION
To retrieve all the items from a public folder on a computer that is running Exchange 2000, follow these steps:  Start Microsoft Visual Studio .NET. On the File menu, point to New, and then click Project. In the Visual Basic Projects types list, click Console Application.

By default, the Module1.vb file is created. Add a reference to Microsoft XML 3.0. To do so, follow these steps:  On the Project menu, click Add Reference. Click the COM tab, locate Microsoft XML v3.0, and then click Select. In the Add References dialog box, click OK.</li> If you are prompted to generate wrappers for the libraries that you selected, click Yes.</li></ol> </li>  In the code window, replace the code with the following: Module Module1

Sub Main Dim oXMLHttp As MSXML2.XMLHTTP30 = New MSXML2.XMLHTTP30 Dim sUrl As String Dim sQuery As String

' TODO: Replace with your folder URL sUrl = &quot;http://ExchSrvr/public/MyFolder/MySubFolder&quot;

' TODO: Replace the domain name, the user name, and the password with your actual ' domain name, user name, and password. oXMLHttp.open(&quot;SEARCH&quot;, sUrl, False, &quot;domain\username&quot;, &quot;password&quot;)

' Find items with Subject = 'Test' sQuery = &quot;<?xml version='1.0'?>&quot; & _ &quot;<g:searchrequest xmlns:g='DAV:'>&quot; & _ &quot;<g:sql>SELECT &quot;&quot;DAV:displayname&quot;&quot; &quot; & _ &quot;FROM SCOPE('SHALLOW TRAVERSAL OF &quot;&quot;&quot; & sUrl & &quot;&quot;&quot;') &quot; & _ &quot;WHERE &quot;&quot;urn:schemas:mailheader:subject&quot;&quot; = 'Test'&quot; & _ &quot;</g:sql>&quot; & _ &quot;</g:searchrequest>&quot;

' Set the request headers. oXMLHttp.setRequestHeader(&quot;Content-Type&quot;, &quot;text/xml&quot;) oXMLHttp.setRequestHeader(&quot;Translate&quot;, &quot;f&quot;) oXMLHttp.setRequestHeader(&quot;Depth&quot;, &quot;0&quot;) oXMLHttp.setRequestHeader(&quot;Content-Length&quot;, &quot;&quot; & sQuery.Length)

' Send the request. oXMLHttp.send(sQuery)

' Output the response. Console.WriteLine(oXMLHttp.status) Console.WriteLine(oXMLHttp.statusText) Console.WriteLine(oXMLHttp.responseText)

' Clean up       oXMLHttp = Nothing End Sub

End Module </li> Search for TODO in the code, and then modify the code for your environment.</li> Press F5 to build and to run the program.</li> Make sure that the DisplayName property of the items in the folder was received.</li></ol>

<div class="references_section">