Click here to Skip to main content
15,885,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can anyone suggest me how to connect to Exchange Mailbox 2010 and retrieve contacts from the Public folder. I have Exchange Mailbox 2010 and I need to connect to Exchange via my .net application and I am using unmanaged API (HTTP request) to connect and retrieve contacts from Exchange Mailbox 2010 public folder. Usually, I have tried with Exchange 2007 and tried to call it with the mailbox URL which connects with the Exchange CAS server and returns the HTTP response back and was able to connect successfully. But, in the same way when I connect using Exchange 2010 mailbox URL am getting HTTP 403: Forbidden Access Error. I also noted that there are some changes in the configuration for Exchange 2010 if compared to Exchange 2007. It would be a great help if anyone could suggest me how to connect or configure the mailbox accordingly so that I can retrieve contacts from the Public folder. In exchange 2007, there was a public virtual directory provided by default, whereas in Exchange 2010, there was no such public virtual directory.

Is there any workaround to add public virtual directory in Exchange mailbox 2010 and connect it via .net application using unmanaged code or any alternative way. Please suggest me?

What I have tried:

This is the Exchange URL format to connect ContactConfiguration.ExchangeURI = "http://<mailbox server-name="">/public/<public folder="" name="">"

List<contact> ContactList = null;
System.Uri myUri = new System.Uri(ContactConfiguration.ExchangeURI);
string sQuery;
sQuery = "" +
"<a:searchrequest xmlns:a="DAV:">" +
"<a:sql>SELECT \"DAV:getlastmodified\",\"DAV:id\",\"DAV:uid\",\"urn:schemas:contacts:cn\",\"zLinkedIn\", \"zJigsaw\", \"zFacebook\",\"zJobHistory\", \"zCompanyMirrorValue\", \"urn:schemas:contacts:personaltitle\", \"urn:schemas:contacts:givenName\", \"urn:schemas:contacts:middlename\", \"urn:schemas:contacts:sn\", \"urn:schemas:contacts:email1\", \"urn:schemas:contacts:email2\", \"urn:schemas:httpmail:textdescription\" " +
"FROM \"" + ContactConfiguration.ExchangeURI + "\" " +
"ORDER BY \"urn:schemas:contacts:email1 \"" +
"" +
"";
HttpWebRequest HttpWRequest = GetWebRequest(myUri);
HttpWRequest.ContentLength = sQuery.Length;
HttpWRequest.Method = "SEARCH";
Byte[] ByteQuery = System.Text.Encoding.ASCII.GetBytes(sQuery);
HttpWRequest.ContentLength = ByteQuery.Length;
using (Stream QueryStream = HttpWRequest.GetRequestStream())
{
QueryStream.Write(ByteQuery, 0, ByteQuery.Length);
}
String sText = GetHttpResponse(HttpWRequest);
HttpWRequest = null;
ContactList = ParseAllContactXML(sText);
Posted
Updated 5-Aug-16 22:41pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900