我需要更精通该领域的人来重新命名问题
我正在尝试了解有关 webDAV 和 .NET 的更多信息。我编写了一个需要从服务器上的收件箱中提取所有电子邮件的应用程序。我需要将这些电子邮件加载到具有以下属性的对象中:
- 从 - 到 - 学科 - 身体
我在这里找到了一个非常有用的帖子。但我不太确定如何操作 xml 文件以匹配我需要的内容。具体如下代码:
XmlDocument document = new XmlDocument();
document.Load(responseStream);
// set up namespaces
XmlNamespaceManager nsmgr = new XmlNamespaceManager(document.NameTable);
nsmgr.AddNamespace("a", "DAV:");
nsmgr.AddNamespace("b", "urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/");
nsmgr.AddNamespace("c", "xml:");
nsmgr.AddNamespace("d", "urn:schemas:mailheader:");
nsmgr.AddNamespace("e", "urn:schemas:httpmail:");
// Load each response (each mail item) into an object
XmlNodeList responseNodes = document.GetElementsByTagName("a:response");
foreach (XmlNode responseNode in responseNodes)
{
// get the <propstat> node that contains valid HTTP responses
XmlNode uriNode = responseNode.SelectSingleNode("child::a:href", nsmgr);
XmlNode propstatNode = responseNode.SelectSingleNode("descendant::a:propstat[a:status='HTTP/1.1 200 OK']", nsmgr);
if (propstatNode != null)
{
// read properties of this response, and load into a data object
XmlNode fromNode = propstatNode.SelectSingleNode("descendant::d:from", nsmgr);
XmlNode descNode = propstatNode.SelectSingleNode("descendant::e:textdescription", nsmgr);
// make new data object
model.Mail mail = new model.Mail();
if (uriNode != null)
mail.Uri = uriNode.InnerText;
if (fromNode != null)
mail.From = fromNode.InnerText;
if (descNode != null)
mail.Body = descNode.InnerText;
unreadMail.Add(mail);
}
}
是否有类似 urn:schemas:httpmail:subject 之类的东西,我可以从中提取主题行?我对 webDAV 非常陌生 - 这是我被告知与 Exchange 服务器交互的方式,所以如果有人能阐明如何修改上述代码以添加主题节点以及为什么 - 我相信我可以弄清楚如何进一步修改它以满足我的需求。
所以为了清楚起见,我的问题是:
如何修改上面的代码片段以包括从 Exchange 服务器提取的电子邮件的主题行?