
February 28, 2009 16:18 by
Simon
Below is the code for creating a public folder in exchange. Basically you need to send a MKCOL WebDav command to the server together with xml to set further options such as whether or not to enable email for the folder.
/// <summary>
/// Creates a public folder in exchange.
/// </summary>
/// <param name="cookies">The cookies returned from previously authenticating.</param>
/// <param name="newFolderURI">The URI for the new folder (must not have a / at the end).</param>
public static void CreateExchangePublicFolder(CookieCollection cookies,
string newFolderURI,
bool enableEmail)
{
StringBuilder options = new StringBuilder();
options.Append("<?xml version=\"1.0\"?>");
options.Append("<d:propertyupdate xmlns:d=\"DAV:\" xmlns:S=\"http://schemas.microsoft.com/security/\" xmlns:exsec=\"http://schemas.microsoft.com/exchange/security/\" xmlns:ex=\"http://schemas.microsoft.com/exchange/\" xmlns:m=\"urn:schemas-microsoft-com:datatypes\" xmlns:mapi=\"http://schemas.microsoft.com/mapi/proptag/\">");
options.Append("<d:set>");
options.Append("<d:prop>");
options.Append("<mapi:0x3FE6000B m:dt=\"boolean\">0</mapi:0x3FE6000B>"); // PUBLISH IN ADDRESS BOOK
options.Append(string.Format("<mapi:0x671F000B m:dt=\"boolean\">{0}</mapi:0x671F000B>", enableEmail ? "1" : "0")); // PROXY REQUIRED
options.Append("</d:prop>");
options.Append("</d:set>");
options.Append("</d:propertyupdate>");
HttpWebResponse response = SendRequest(cookies, newFolderURI, "MKCOL", null, options.ToString());
response.Close();
}
ab4c57a3-9c51-467e-accb-f33e50c6cbb1|0|.0