簡體   English   中英

使用webDAV和.NET獲取電子郵件的主題行

[英]Getting subject line of e-mail using webDAV and .NET

  1. 我需要一個更精通這一領域的人來重新命名這個問題

  2. 我正在嘗試了解有關webDAV和.NET的更多信息。 我編寫了一個需要從服務器上的收件箱中提取所有電子郵件的應用程序。 我需要將這些電子郵件加載到具有以下屬性的對象中:

- From 
 - To
 - Subject
 - Body

我在這里找到了非常有幫助的帖子。 但是我不太確定如何操作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服務器提取的電子郵件的主題行?

看到這里 ,嘗試urn:schemas:httpmail:subject它應該可以工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM