本文介绍了如何阅读Exchange数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正在创建一个必须从Microsoft Exchange中读取和更新联系人信息(例如电话号码,电子邮件等)的应用程序...
im creating an application that have to read and update Contacts Information (like phone number, email, etc..) from Microsoft Exchange...
任何一个知道如何连接到MS Exchange数据库?
Does any one know how can i connect to a MS Exchange DB ??
推荐答案
WebDAV是我使用的...
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();
}
这就是我的调用方式
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
这篇关于如何阅读Exchange数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!