Re: WebDAV mark as read?



Hi

I am using following code to change the message read/unread status. In
response this code create new mail only with subject and their is no change
in message read/unread status.

Can you please help me in this.

thanks in advance

Here is the code


try
{
MyCredentialCache = new System.Net.CredentialCache();
MyCredentialCache.Add(new System.Uri(sUri),
"NTLM",
new System.Net.NetworkCredential(strUserName, strPassword,
strDomain)
);

// TODO: Replace with the URL of an object in Exchange Server

System.Uri myUri = new System.Uri(sUri);
HttpWRequest = (HttpWebRequest)WebRequest.Create(myUri);

// Add the network credentials to the request.
HttpWRequest.Credentials = MyCredentialCache;

string sQuery;
sQuery = "<?xml version='1.0'?>"
+ " <D:propertyupdate
xmlns:b='urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/'
xmlns:e='urn:schemas:httpmail:' xmlns:z='urn:schemas:mailheader:'
xmlns:c='xml:' xmlns:f='http://schemas.microsoft.com/exchange/'
xmlns:g='urn:schemas-microsoft-com:office:office'
xmlns:h='http://schemas.microsoft.com/repl/'
xmlns:i='urn:schemas-microsoft-com:exch-data:' xmlns:D='DAV:'>"
+ " <D:set><D:prop><e:read
b:dt='boolean'>1</e:read></D:prop></D:set>"
+ " </D:propertyupdate>";

// Set Headers
HttpWRequest.KeepAlive = true;
HttpWRequest.Headers.Set("Pragma", "no-cache");
//HttpWRequest.Headers.Set("Translate", "f");
HttpWRequest.ContentType = "text/xml";
HttpWRequest.ContentLength = sQuery.Length;

//set the request timeout to 5 min.
HttpWRequest.Timeout = 300000;
// set the request method
HttpWRequest.Method = "PROPPATCH";

// You must store the data in a byte array
byte[] ByteQuery = System.Text.Encoding.ASCII.GetBytes(sQuery);
HttpWRequest.ContentLength = ByteQuery.Length;
Stream QueryStream = HttpWRequest.GetRequestStream();
// Write the data to be posted to the Request Stream
QueryStream.Write(ByteQuery, 0, ByteQuery.Length);
QueryStream.Close();

// Send Request and Get Response
HttpWebResponse HttpWResponse =
(HttpWebResponse)HttpWRequest.GetResponse();

// Get the Status code
int iStatCode = (int)HttpWResponse.StatusCode;
string sStatus = iStatCode.ToString();
Console.WriteLine("Status Code: {0}", sStatus);
// Get the request headers
string sReqHeaders = HttpWRequest.Headers.ToString();
Output += sReqHeaders;

// Read the Response Stream
Stream strm = HttpWResponse.GetResponseStream();
StreamReader sr = new StreamReader(strm);
string sText = sr.ReadToEnd();
Output += "\n Response: {0}"+ sText;

strm.Close();

MyCredentialCache = null;
HttpWRequest = null;
HttpWResponse = null;
QueryStream = null;
strm = null;
sr = null;
}
catch (Exception e)
{
Output = "\n {0} Exception caught." + e.Message;
}


"sameen" wrote:

Can you please guide me how can i use this flag (PR_MESSAGEFLAGS) from C#
WebDAV Application?


"sameen" wrote:

How you please guide me how can i use this flag (PR_MESSAGEFLAGS) from C#
WebDAV Application?

"Luke" wrote:

Yeah, I tried that too. Eventually I figured out that adding "no-cache"
headers to all my requests fixed everything.

"Henning Krause [MVP - Exchange]" wrote:

Hello,

try to set bit 0 of http://schemas.microsoft.com/mapi/proptag/xe070003
(PR_MESSAGEFLAGS) to 1.

Haven't tried that, but looks promising.

Best regards,
Henning Krause


"Luke" <Luke@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5F15328B-949E-46B7-A925-99FFAB800B72@xxxxxxxxxxxxxxxx
I'm using WebDAV on Exchange 2003. I am looking for unread messages with
attachments then downloading those attachments. This part works fine.
The
problem is that setting the "urn:schemas:httpmail:read" attribute seems to
do
nothing. It doesn't mark read messages as unread and it doesn't mark
unread
messages as read. The PROPPATCH response indicates success, but it is not
reflected in the store on the server. I spent hours looking at various
resources, but couldn't find anything. What could be causing this?


.



Relevant Pages

  • Re: HttpWebRequest.GetRequestStream times out
    ... When I encounter this exception, this is printed in the log: ... Stream sendStream = httpReq.GetRequestStream; ... you never read more than 1 kB of the response, ... The request timeout is set to 100 seconds, and the requests that time out ...
    (microsoft.public.dotnet.framework.performance)
  • Re: problem WebRequest and WebResponse
    ... the Stream and the WebResponse instances. ... HttpWebRequest request = ... WebResponse response = null; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: NotificationSampleWebDav-Monitor OWA Inbox
    ... re-login or update your cookie with each response you get... ... Warning: Exiting Action with an exception: The remote server returned an ... // Create request object and assign credentials. ... Stream newStream = Request.GetRequestStream; ...
    (microsoft.public.exchange.applications)
  • Re: Close OWA Connection
    ... established my connection to OWA to terminate the connection?!? ... HttpWebRequest request; ... HttpWebResponse response; ... Stream stream; ...
    (microsoft.public.exchange.development)
  • Re: W2K3 IIS 6.0 ASP.NET Requests Per Second Limits?
    ... allow the page to tell ASP.Net "don't send a response yet until I tell ... this request is "leaked" and will never ... It is when the callback executes with both the async function call ... The thread executing code literally calls into Function1, execute code, ...
    (microsoft.public.inetserver.iis)

Loading