Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q314180

↑ Back to the top


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.

↑ Back to the top


More information

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

By default, the Module1.vb file is created.
4.Add a reference to Microsoft XML 3.0. To do so, follow these steps:
a. On the Project menu, click Add Reference.
b. Click the COM tab, locate Microsoft XML v3.0, and then click Select.
c. In the Add References dialog box, click OK.
d. If you are prompted to generate wrappers for the libraries that you selected, click Yes.
5.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 = "http://ExchSrvr/public/MyFolder/MySubFolder"

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

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

        ' Set the request headers.
        oXMLHttp.setRequestHeader("Content-Type", "text/xml")
        oXMLHttp.setRequestHeader("Translate", "f")
        oXMLHttp.setRequestHeader("Depth", "0")
        oXMLHttp.setRequestHeader("Content-Length", "" & 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
					
6.Search for TODO in the code, and then modify the code for your environment.
7.Press F5 to build and to run the program.
8.Make sure that the DisplayName property of the items in the folder was received.

↑ Back to the top


References

For information about the WebDAV protocol, visit the following MSDN Web site:

↑ Back to the top


Keywords: KB314180, kbxml, kbhowto

↑ Back to the top

Article Info
Article ID : 314180
Revision : 4
Created on : 7/21/2004
Published on : 7/21/2004
Exists online : False
Views : 503