Microsoft Knowledge Base Email Alertz

(314180) - Describes how to use Microsoft XML 3.0 and Visual Basic .NET to retrieve all the items in a public folder on a computer that is running Exchange 2000. Includes a code sample that you can use to retrieve the items.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 314180 - Last Review: July 21, 2004 - Revision: 1.4

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

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:
  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:
    1. On the Project menu, click Add Reference.
    2. Click the COM tab, locate Microsoft XML v3.0, and then click Select.
    3. In the Add References dialog box, click OK.
    4. 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.

REFERENCES

For information about the WebDAV protocol, visit the following MSDN Web site:
http://msdn.microsoft.com/en-us/library/aa143161(EXCHG.65).aspx (http://msdn.microsoft.com/en-us/library/aa143161(EXCHG.65).aspx)

APPLIES TO
  • Microsoft Exchange 2000 Server Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft XML Parser 3.0
  • Microsoft XML Core Services 4.0
Keywords: 
kbhowto kbxml KB314180
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate