using System;
using System.Reflection;
namespace WebDav
{
class Class1
{
public static void Main(String [] args)
{
try
{
MSXML2.XMLHTTP30 oXMLHttp = new MSXML2.XMLHTTP30();
//TODO: To list items, uncomment "const bool bListItems = false;"
const bool bListFolders = true;
//const bool bListItems = false;
String sUrl;
//TODO: Replace ExchServer with your Exchange server and UserAlias with your user alias.
sUrl= "http://ExchServer/Exchange/UserAlias/Inbox";
oXMLHttp.open("SEARCH", sUrl, false, "UserDomain\UserAlias", "UserPassword");
//TODO: Use this query to list items.
/*String sQuery;
sQuery = "<?xml version='1.0'?>" +
"<g:searchrequest xmlns:g='DAV:'>" +
"<g:sql>SELECT \"DAV:displayname\" " +
"FROM SCOPE('SHALLOW TRAVERSAL OF \"" + sUrl + "\"')" +
" WHERE \"DAV:isfolder\" = " + bListItems.ToString()+
"</g:sql>" +
"</g:searchrequest>";
*/
//TODO: Use this query to list folders.
String sQuery;
sQuery = "<?xml version='1.0'?>" +
"<g:searchrequest xmlns:g='DAV:'>" +
"<g:sql>SELECT \"DAV:displayname\" " +
"FROM SCOPE('SHALLOW TRAVERSAL OF \"" + sUrl + "\"')" +
" WHERE \"DAV:isfolder\" = " + bListFolders.ToString() +
"</g:sql>" +
"</g:searchrequest>";
oXMLHttp.setRequestHeader("Content-Type", "text/xml");
oXMLHttp.setRequestHeader("Translate", "f");
oXMLHttp.setRequestHeader("Content-Length", "" + sQuery.Length);
Console.WriteLine(sQuery);
oXMLHttp.send(sQuery);
Console.WriteLine(oXMLHttp.status);
Console.WriteLine(oXMLHttp.statusText);
Console.WriteLine(oXMLHttp.responseText);
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
}
}