views:

507

answers:

4

Hello, im creating an application that have to read and update Contacts Information (like phone number, email, etc..) from Microsoft Exchange...

Does any one know how can i connect to a MS Exchange DB ??

+1  A: 

You will have to use Extended MAPI, it is not a standard SQL database.

Otávio Décio
hmmm... can u give me more information... im using c# and i just want to Update / Insert Exchange contacts information
+2  A: 

WebDAV is what i use...

Here's a function i wrote to access our exchange server (be kind i wrote it years ago).. (:

 /// <summary>
    /// Returns XML string for a specific query
    /// </summary>
    /// <param name="Query"></param>
    /// <param name="Account"></param>
    /// <param name="Folder"></param>
    /// <returns></returns>
    private string ProcessRequest(string Query, string Account, string Folder) {

     System.Net.WebRequest req = WebRequest.Create("http://" + MailServer + "/exchange/" + Account + "/" + Folder);
      req.Headers.Add("Depth", "1");
      req.Headers.Add("Brief", "t");
      req.Credentials = ncCurrent;

      Byte[] bytes  = System.Text.Encoding.ASCII.GetBytes(Query);
      req.ContentType = "text/xml";
      req.ContentLength = bytes.Length;
      req.Method = "SEARCH";

      System.IO.Stream oStreamOut = req.GetRequestStream();
      oStreamOut.Write(bytes, 0, bytes.Length);
      oStreamOut.Close();

      WebResponse rsp = req.GetResponse();
      System.IO.Stream oStreamIn = rsp.GetResponseStream();
      System.IO.StreamReader oStreamRead = new System.IO.StreamReader(oStreamIn);
      return oStreamRead.ReadToEnd();
}

and here's how i invoke it

  string xmldata = "<?xml version= \"1.0\"?>" +
    "<g:searchrequest xmlns:g=\"DAV:\">" +
      "<g:sql> Select \"DAV:href\" , \"urn:schemas:httpmail:subject\" " + 
      "FROM Scope('SHALLOW TRAVERSAL OF \"/exchange/" + Account + "/" + Folder + "\"') " +
      "</g:sql>" +
    "</g:searchrequest>";



  XmlDocument d = new XmlDocument();
  d.LoadXml(ProcessRequest(xmldata, Account, Folder));

hopefully this points you in the right direction

Rob
hmmm... can u give me more information... im using c# and i just want to Update / Insert Exchange contacts information
Eek... I've only done reads, but if you figure that part out, coudl you let <me> know.. thanks.. I have successfully read calendars and inboxes.. haven't tried anything with contacts. there are MSDN references for webdav and it seems like it's a "standard"...
Rob
ok Rob ill investigate and let u know if found something that works... thanks any way
+1  A: 

If you are using Exchange 2007 you can use Exchange Web Services

Sam Cogan
+1  A: 

You can:

Use ExtendedMAPI. Look for MAPI33 on the 'net. It has examples of what you want to do I think.

Use the web services. Thats the preferred way in 2007

WebDAV also works, but I dont think it works in 2007 at all?

MAPI is the best way, but it's not officially supported in .NET (tho it works), and it does NOT AT ALL work in 64bit mode. It's 32 bit only.

Nic Wise