Microsoft Knowledge Base Email Alertz

KBAlertz.com: (291171) - This article demonstrates how to list all the folders of a folder hierarchy by using Web Distributed Authoring and Versioning (WebDAV).

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]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **


Bug Tracking Software
For bug tracking software or defect tracking software or issue tracking software, visit Axosoft.


Community Site



We Send hundreds of thousands of emails using ASP.NET Email



Expert Web Design & Graphic Design
Design44.com

ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
The ad says 3 - but KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

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




Article ID: 291171 - Last Review: May 9, 2007 - Revision: 4.5

How To List Public Folders by Using WebDAV

This article was previously published under Q291171

SUMMARY

This article demonstrates how to list all the folders of a folder hierarchy by using Web Distributed Authoring and Versioning (WebDAV).

MORE INFORMATION

To list all of the folders in the public folder hierarchy, follow these steps:
  1. In Microsoft Visual Basic, create a Standard EXE project. Form1 is created by default.
  2. Add a command button to Form1 and name the button Command1.
  3. Add a reference to the MSXML object library.
  4. Paste the following code in the code section of Form1.NOTE: Change e2kServer in the code to the name of your Exchange server.
    Private Sub Command1_Click()
       Dim strURL As String
       Dim sUserID As String
       Dim sPassword As String
       strURL = "http://e2KServer/public"
       sUserID = "UserID" 'TODO 
       sPassword = "password" 'TODO
       ListFolders strURL, sUserID, sPassword
    End Sub
    
    Sub ListFolders(ByVal strURL As String, ByVal sUserID As String, _
    ByVal sPassword As String)
       Dim oDoc As MSXML.DOMDocument
       Dim oDocBack As MSXML.DOMDocument
    
       Dim oNode As IXMLDOMElement
       Dim oNode2  As IXMLDOMElement
       Dim req As MSXML.XMLHTTPRequest
    
       Set oDoc = CreateObject("MICROSOFT.XMLDOM")
       Set oDocBack = CreateObject("MICROSOFT.XMLDOM")
       
       MSXML 4.0 
       Dim oDoc As MSXML2.DOMDocument40
       Dim oDocBack As MSXML2.DOMDocument40
       Dim req As MSXML2.XMLHTTP40
       Set oDoc = CreateObject("MSXML2.DomDocument.4.0")
       Set oDocBack = CreateObject("MSXML2.DomDocument.4.0")
       
       Set pi = oDoc.createProcessingInstruction("xml", "version=""1.0""")
       oDoc.appendChild pi
    
       Set oNode = oDoc.createNode(1, "searchrequest", "DAV:")
       Set oDoc.documentElement = oNode
    
       Set oNode2 = oDoc.createNode(1, "sql", "DAV:")
       oNode.appendChild oNode2
       strQuery = "Select ""DAV:displayname"" From "
       strQuery = strQuery & "Scope('Shallow Traversal of """ & strURL & """')"
       Set query = oDoc.createTextNode(strQuery)
       oNode2.appendChild query
    
       Set req = CreateObject("microsoft.xmlhttp")
       req.open "SEARCH", strURL, False, sUserID, sPassword
       req.setRequestHeader "Translate", "f"
       req.setRequestHeader "Content-Type", "text/xml"
       req.setRequestHeader "Depth", "0"
       req.send oDoc
    
       Set oDocBack = req.responseXML
    
       Dim objNodeList
    
       'Typically the DAV namespace get the 'a' prefix.
       'If you are specifying multiple properties in a search, examine the 
       'returned XML beforehand to determine prefixes for your code.
    
       Set objNodeList = oDocBack.getElementsByTagName("a:displayname")
       For i = 0 To (objNodeList.length - 1)
         Set objNode = objNodeList.nextNode
         Debug.Print objNode.Text
       Next
    End Sub
    					
  5. Run the project.

REFERENCES

For more information about WebDAV, see the WebDAV book in the Exchange SDK, and the WebDAV Sample Application in the "Solutions" section of the Exchange SDK, located at the following Web site:
http://msdn2.microsoft.com/en-us/exchange/default.aspx (http://msdn2.microsoft.com/en-us/exchange/default.aspx)

APPLIES TO
  • Microsoft Exchange 2000 Server Standard Edition
  • Microsoft XML Parser 2.0
  • Microsoft XML Core Services 4.0
Keywords: 
kbhowto kbmsg KB291171
       

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

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please