views:

555

answers:

1
  1. I need someone more well versed in this area to re-title the question

  2. I am trying to learn more about webDAV and .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. 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? 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.

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?

A: 

see here, try urn:schemas:httpmail:subject it should work

ArsenMkrt