[英]Getting subject line of e-mail using webDAV and .NET
I need someone more well versed in this area to re-title the question 我需要一个更精通这一领域的人来重新命名这个问题
I am trying to learn more about webDAV and .NET. 我正在尝试了解有关webDAV和.NET的更多信息。 I have written an app that needs to pull all e-mails from an inbox on the server.
我编写了一个需要从服务器上的收件箱中提取所有电子邮件的应用程序。 I need to load these e-mails into an object that has the following properties:
我需要将这些电子邮件加载到具有以下属性的对象中:
- From - To - Subject - Body
I found a VERY helpful post here . 我在这里找到了非常有帮助的帖子。 But I'm not quite sure how to manipulate the xml file to match what I need.
但是我不太确定如何操作xml文件来匹配我需要的文件。 Specifically the following code:
具体来说,以下代码:
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);
}
}
Is there like a urn:schemas:httpmail:subject or something like that where I can pull the subject line out? 是否有像urn:schemas:httpmail:subject之类的东西或类似的东西可以拉出主题行? I am VERY VERY new to webDAV - and this is the way that I have been told to interact with the Exchange server so if anyone can shed any light on how to modify the above code to add a subject node and WHY - I am sure I can figure out how to modify it further to meet my needs.
我对webDAV非常陌生-这是我被告知与Exchange服务器进行交互的方式,因此,如果有人可以对如何修改上述代码以添加主题节点和为什么有所了解-我确定可以找出如何进一步修改以满足我的需求。
So just to be clear, my question is this: 因此,为了清楚起见,我的问题是:
How can I modify the above code snippet to also include the subject line of an e-mail pulled off an Exchange server? 如何修改上面的代码片段,使其也包含从Exchange服务器提取的电子邮件的主题行?
看到这里 ,尝试urn:schemas:httpmail:subject它应该可以工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.