// Encode the body using UTF-8.
bytes = Encoding.UTF8.GetBytes((string)strQuery);
// Set the content header length.. This must be
// done before writing data to the request stream.
Request.ContentLength = bytes.Length;
// Get a reference to the request stream.
RequestStream = Request.GetRequestStream();
// Write the SQL query to the request stream.
RequestStream.Write(bytes, 0, bytes.Length);
// Close the Stream object to release the connection
// for further use.
RequestStream.Close();
// Set the content type header.
Request.ContentType = "text/xml;charset="utf-8"";
// Send the SEARCH method request and get the
// response from the server.
Response = (HttpWebResponse)Request.GetResponse();
// Get the XML response stream.
ResponseStream = Response.GetResponseStream();
// Create the XmlDocument object from the XML response stream.
ResponseXmlDoc = new XmlDocument();
ResponseXmlDoc.Load(ResponseStream);
strEmailXml = ResponseXmlDoc.InnerXml;
ResponseStream.Close();
Response.Close();
}
catch (Exception e)
...{
// Catch any exceptions. Any error codes from the SEARCH
// method request on the server will be caught here, also.
return "";
}
return strEmailXml;
} 返回的也是XML串,经过一些处理便可以以一定的格式展示邮件的信息了
代码的关键是 strQuery的XML查询串
相关语法及信息可以参考:
http://msdn2.microsoft.com/en-us/library/ms527286.aspx
从这里可以找到各种字段和命名空间的意义.