How to read de Exchange Database?

2019-08-01 11:02发布

问题:

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:

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



回答2:

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



回答3:

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



回答4:

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.



回答5:

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.