leederbyshire.com  Mobile web applications for Microsoft Exchange Server.
HOME OWA FOR PDA BUY ONLINE DOWNLOADS TESTIMONIALS SCREENSHOTS FAQ MANUAL (WIP) UPGRADE ARTICLES CONTACT

EWS FindFolder List Search Folders Exchange 2010

LISTING YOUR SEARCH FOLDERS WITH EWS FINDFOLDER

Back to Articles page

Here's a short article describing how you can use the Exchange Web Services (EWS) FindFolder operation to list the search folders in your Mailbox.

I'm not going to go into too much detail, but it is a demonstration of how you can use the FindFolder operation to return a list of your Search Folders. The output is then displayed using XSL. Copy the code into an .htm file, and then open it in Internet Explorer. Change the http to https if necessary (probably not), supply the name of your Exchange server, and click the button. It may ask you to login.

Hopefully, you will be rewarded with a list of your Search Folders.

<html>
<head>
<script language="VBScript">

Dim objXMLHTTP, objXMLDoc

Sub getFolders_OnClick()
  strProtocol = document.all.protocol.value
  strServerName = document.all.server.value
  strURL = strProtocol & "://" & strServername & "/EWS/Exchange.asmx"
  Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")
  objXMLHTTP.Open "POST", strURL, True
  objXMLHTTP.setRequestHeader "Content-type:", "text/xml"
  objXMLHTTP.onReadyStateChange = getRef("checkXMLHTTPState")
  strXML = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
   "<soap:Envelope xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""" & _
   " xmlns:m=""http://schemas.microsoft.com/exchange/services/2006/messages""" & _
   " xmlns:t=""http://schemas.microsoft.com/exchange/services/2006/types"">" & _
   "<soap:Body>" & _
   "<m:FindFolder Traversal=""Shallow"">" & _
   "<m:FolderShape>" & _
   "<t:BaseShape>Default</t:BaseShape>" & _
   "</m:FolderShape>" & _
   "<m:ParentFolderIds>" & _
   "<t:DistinguishedFolderId Id=""searchfolders""/>" & _
   "</m:ParentFolderIds>" & _
   "</m:FindFolder>" & _
   "</soap:Body>" & _
   "</soap:Envelope>"
  objXMLHTTP.Send(strXML)
End Sub

Sub checkXMLHTTPState
  If objXMLHTTP.readyState = 4 Then
    responseStatus.innerHTML = objXMLHTTP.Status & " - " & objXMLHTTP.StatusText
    Set objXMLDoc = objXMLHTTP.ResponseXML
    XSLDiv.innerHTML = objXMLDoc.TransformNode(responseXSL.documentElement)
    Set objXMLHTTP = Nothing
    Set objXMLDoc = Nothing
  End If
End Sub

</script>
<xml id="responseXSL">
<xsl:template xmlns:xsl="uri:xsl" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
  <xsl:for-each select="//t:SearchFolder">
    <xsl:value-of select="t:DisplayName"/><br/>
  </xsl:for-each>
</xsl:template>
</xml>

</head>
<body>
<font face="Sans-serif" size="2">
<input name="protocol" value="http" size="5">://<input name="server">
<input type="button" name="getFolders" value="GO">
<span id="responseStatus"></span>
<p>
<div id="XSLDiv"></div>
</body>
</html>

Outlook Web With Windows Mobile
Copyright © 2017 Lee Derbyshire. All rights reserved.