G
Guest
First, apologies for cross-posting. I posted this message originally in
exchange2000.development, but it looks like that's an unmanaged group. At
least it doesn't show up in the list when looking at the managed groups...
Here's the original post:
I'm writing an ASP .net web application that (in part) adds a calendar item
to the user's Exchange mailbox. I "stole" some code that many people seem to
be using, and it works great as long as I run the application from the local
machine. When I hit the application from another machine, I get a 401 when
attempting the post.
I have annonymous turned off, and I'm attempting to add to my own calendar.
Here's my code:
public void SendQuery(string packageXml)
{
Byte[] packageBytes;
Stream requestStream;
Stream responseStream;
StreamReader reader;
string responseText;
System.Uri myUri = new
Uri("http://srvexchbnt01/exchange/KEVIN.SWANSON/Calendar/20040929123012.eml");
WebRequest httpRequest = HttpWebRequest.Create(myUri);
//use Integrated Windows authentication.
httpRequest.Credentials = CredentialCache.DefaultCredentials;
// add the keep-alive header
httpRequest.Headers.Add("HTTP_CONNECTION", "Keep-Alive");
//Set Headers.
httpRequest.Headers.Set("Pragma", "no-cache");
httpRequest.ContentType = "text/xml";
httpRequest.ContentLength = packageXml.Length;
//Set the request timeout to 5 minutes.
httpRequest.Timeout = 10000;
//Set the request method.
httpRequest.Method = "PROPPATCH";
//The data must be stored in a byte array.
packageBytes = System.Text.Encoding.ASCII.GetBytes(packageXml);
httpRequest.ContentLength = packageBytes.Length;
requestStream = httpRequest.GetRequestStream();
//Write the data to be posted to the Request Stream.
requestStream.Write(packageBytes, 0, packageBytes.Length);
requestStream.Close();
//Get Response Stream.
responseStream = httpRequest.GetResponse().GetResponseStream();
//Read the Response Steam.
reader = new StreamReader(responseStream);
responseText = reader.ReadToEnd();
//Close the Stream.
responseStream.Close();
}
exchange2000.development, but it looks like that's an unmanaged group. At
least it doesn't show up in the list when looking at the managed groups...
Here's the original post:
I'm writing an ASP .net web application that (in part) adds a calendar item
to the user's Exchange mailbox. I "stole" some code that many people seem to
be using, and it works great as long as I run the application from the local
machine. When I hit the application from another machine, I get a 401 when
attempting the post.
I have annonymous turned off, and I'm attempting to add to my own calendar.
Here's my code:
public void SendQuery(string packageXml)
{
Byte[] packageBytes;
Stream requestStream;
Stream responseStream;
StreamReader reader;
string responseText;
System.Uri myUri = new
Uri("http://srvexchbnt01/exchange/KEVIN.SWANSON/Calendar/20040929123012.eml");
WebRequest httpRequest = HttpWebRequest.Create(myUri);
//use Integrated Windows authentication.
httpRequest.Credentials = CredentialCache.DefaultCredentials;
// add the keep-alive header
httpRequest.Headers.Add("HTTP_CONNECTION", "Keep-Alive");
//Set Headers.
httpRequest.Headers.Set("Pragma", "no-cache");
httpRequest.ContentType = "text/xml";
httpRequest.ContentLength = packageXml.Length;
//Set the request timeout to 5 minutes.
httpRequest.Timeout = 10000;
//Set the request method.
httpRequest.Method = "PROPPATCH";
//The data must be stored in a byte array.
packageBytes = System.Text.Encoding.ASCII.GetBytes(packageXml);
httpRequest.ContentLength = packageBytes.Length;
requestStream = httpRequest.GetRequestStream();
//Write the data to be posted to the Request Stream.
requestStream.Write(packageBytes, 0, packageBytes.Length);
requestStream.Close();
//Get Response Stream.
responseStream = httpRequest.GetResponse().GetResponseStream();
//Read the Response Steam.
reader = new StreamReader(responseStream);
responseText = reader.ReadToEnd();
//Close the Stream.
responseStream.Close();
}