Problem in setting Public Folder properties using WebDav

Hi,

I have successfully created Public Folder using WebDav "MKCOL" method but I have been facing problems in setting its properties. I just want to make created public folder as mail enabled and want to set its smtp address but I don't know though return status is success - 207 Multi Status of my given code,  it doesn't set mail enabled property and hence also doesn't set smtp address. Could anyone please help me on this. It would be much appreciated.

Thanks.
private static bool setFolderProperties(string pfPath, string mailEnable, string smtpAddress)
        {
            try
            {
                byte[] bytes = null;
                System.IO.Stream RequestStream = null;
 
                StringBuilder result = new StringBuilder("<?xml version=\"1.0\"?>");
                result.Append("<a:propertyupdate ")
                       .Append("xmlns:a=\"DAV:\" ")
                       .Append("xmlns:e=\"http://schemas.microsoft.com/exchange/\" ")
                       .Append("xmlns:b=\"urn:schemas-microsoft-com:datatypes\" ")
                       .Append("xmlns:p=\"http://schemas.microsoft.com/mapi/proptag/\">")
                       .Append("<a:set><a:prop>")
                       .Append("<e:outlookfolderclass>IPF.Folder</e:outlookfolderclass>")
                       .Append("<a:contentclass>urn:content-classes:folder</a:contentclass>")
                       .Append("<p:0x3FE6000B b:dt=\"boolean\">1</p:0x3FE6000B>")
                       .Append("<p:0x671F000B b:dt=\"boolean\">1</p:0x671F000B>")
                       .Append("<e:publicfolderemailaddress>" + smtpAddress + "</e:publicfolderemailaddress>")
                       .Append("</a:prop></a:set>")
                       .Append("</a:propertyupdate>");
 
                Console.WriteLine("Properties:\n " + (string)result.ToString());
 
                System.Uri pfUri = new System.Uri(pfPath);
                // Create the HttpWebRequest object.
                WebRequest Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(pfUri);
                Request.Credentials = CredentialCache.DefaultCredentials;
                Request.Method = "PROPPATCH";
                Request.ContentType = "text/xml";
                Request.ContentLength = result.Length;
                Request.Headers.Add("Translate", "f");
 
                // Encode the body using UTF-8.
                bytes = Encoding.UTF8.GetBytes((string)result.ToString());
 
                // Set the content header length.  This must be
                // done before writing data to the request stream.
                Request.ContentLength = bytes.Length;
 
                // Get a reference to the request stream.
                RequestStream = Request.GetRequestStream();
 
                // Write the message body to the request stream.
                RequestStream.Write(bytes, 0, bytes.Length);
 
                // Close the Stream object to release the connection
                // for further use.
                RequestStream.Close();
 
                // Get the response from the server.
                // Expected response: 207 Multi-Status - HTTP_MULTI_STATUS  - The action was successfully received, understood, 
                // and accepted. Indicates that the clients request was successfully received, understood, and accepted.
 
                WebResponse Response = Request.GetResponse();
                Console.WriteLine("Status(Property settings): " + ((HttpWebResponse)Response).StatusCode + " : " + ((HttpWebResponse)Response).StatusDescription);
                Response.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception while setting properties: " + ex.Message);
                Console.WriteLine("Stack Trace: " + ex.StackTrace);
                return false;
            }
            return true;
        }

Open in new window

LVL 1
deshawAsked:
Who is Participating?
 
deshawAuthor Commented:
This problem has been solved by getting rid of
 .Append("<e:publicfolderemailaddress>" + smtpAddress + "</e:publicfolderemailaddress>")

We cannot set email address using WebDav. for that we have to use CDOEX or ADSI.
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.