1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/**************************************
// config pour boite mail
string strInboxURI = "http://monserveur/exchange/nomdelaboiteMail/repertoireaexaminer";
string strUserName = "monnom";
string strPassword = "pwd";
string strDomain = "domaine";
string strQuery = "";
string strQueryDEL = "";
byte[] bytes = null;
System.IO.Stream RequestStream = null;
System.IO.Stream ResponseStream = null;
XmlDocument ResponseXmlDoc = null;
XmlNodeList DisplayNameNodes = null;
var varsite = "sitedeprovenancedumail";
strQuery = "<?xml version=\"1.0\"?><D:searchrequest xmlns:D = \"DAV:\" >"
+ "<D:sql>SELECT * FROM \"" + strInboxURI + "\""
+ " WHERE \"DAV:ishidden\" = false AND \"DAV:isfolder\" = false "
+ " AND \"urn:schemas:httpmail:read\" = false "
+ " AND \"urn:schemas:httpmail:textdescription\" LIKE '%" + varsite + "%' "
//+ " AND LEFT(\"urn:schemas:httpmail:textdescription\",15) LIKE '%" + varsite + "%' "
+ "</D:sql></D:searchrequest>";
strQueryDEL = "<?xml version=\"1.0\"?><D:DELrequest xmlns:D = \"DAV:\" >"
+ "<D:sql>DELETE * FROM \"" + strInboxURI + "\""
+ " WHERE \"DAV:ishidden\" = false AND \"DAV:isfolder\" = false "
+ " AND \"urn:schemas:httpmail:read\" = false "
+ " AND \"urn:schemas:httpmail:textdescription\" LIKE '%" + varsite + "%' "
//+ " AND LEFT(\"urn:schemas:httpmail:textdescription\",15) LIKE '%" + varsite + "%' "
+ "</D:sql></D:DELrequest>";
//---------------------------------------------------------------------------
// Create a new CredentialCache object and fill it with the network
// credentials required to access the server.
MyCredentialCache = new System.Net.CredentialCache();
MyCredentialCache.Add(new System.Uri(strInboxURI),
"NTLM",
new System.Net.NetworkCredential(strUserName, strPassword, strDomain)
);
// Create the HttpWebRequest object.
Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(strInboxURI);
// Add the network credentials to the request.
Request.Credentials = MyCredentialCache;
// Specify the method.
Request.Method = "SEARCH";
// 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";
// Send the SEARCH method request and get the
// response from the server.
Response = (HttpWebResponse)Request.GetResponse();
// Get the XML response stream.
ResponseStream = Response.GetResponseStream(); |
Partager