testing
testing

Reputation:

How to read de Exchange Database?

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 ??

Upvotes: 1

Views: 3466

Answers (5)

TimPe
TimPe

Reputation: 44

You could use the ExchangeManagmentShell and issue powershell commands like set-mailbox to change the e-mail address.

But if you only want to update the phonenumber, roomnumber, etc . This is all stored in the ActiveDirectory.

Upvotes: 0

Nic Wise
Nic Wise

Reputation: 8129

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.

Upvotes: 1

Sam Cogan
Sam Cogan

Reputation: 4334

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

Upvotes: 1

Rob
Rob

Reputation: 2110

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

Upvotes: 2

Ot&#225;vio D&#233;cio
Ot&#225;vio D&#233;cio

Reputation: 74290

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

Upvotes: 1

Related Questions