409 conflict?

409 conflict?

Post by Adam Righ » Wed, 10 May 2006 22:13:32


Hi,

I am using HTTPWebRequest to write an email file to exhchange server, and
using HttpWebResponse. But when webresponse is executed it gives an error
409 "remote server returned error". what can be the problem? Thanks..
 
 
 

409 conflict?

Post by Henning Kr » Wed, 10 May 2006 22:49:07

Hello,

a 409 usually indicates that the parent folder does not exist.

It would help a lot, if you post your code here along with the urls you use.

Greetings,
Henning Krause

 
 
 

409 conflict?

Post by Adam Righ » Wed, 10 May 2006 23:35:26

Hi,

Here is my part of code for sending mail...

#region MailBox
// Build the mailbox URI.
strMailboxURI = "http://" + strServer + "/exchange/" + strAlias;
#endregion

#region Gderen Submission
strSubURI = "http://" + strServer + "/exchange/" + strAlias
+ "/##DavMailSubmissionURI##/";
#endregion

#region Draft
strTempURI = "http://" + strServer + "/exchange/" + strAlias
+ "/drafts/" + strSubject + ".eml";
#endregion

#region Message
strBody = "To: " + strTo + "\n" +
"Cc: " + strToCC + "\n" +
"Subject: " + strSubject + "\n" +
"Date: " + System.DateTime.Now +
"X-Mailer: test mailer" + "\n" +
"MIME-Version: 1.0" + "\n" +
"Content-Type: text/plain;" + "\n" +
"Charset = \"iso-8859-9\"" + "\n" +
"Content-Transfer-Encoding: 7bit" + "\n" +
"\n" + strText;
#endregion

#region Credentials

MyCredentialCache = new System.Net.CredentialCache ( );
MyCredentialCache.Add ( new Uri ( strMailboxURI ) , "NTLM" , new
NetworkCredential ( strAlias , strPassword , strDomain ) );
MyCredentialCache.Add ( new Uri ( strMailboxURI ) , "Basic" , new
NetworkCredential ( strAlias , strPassword , strDomain ) );
MyCredentialCache.Add ( new Uri ( strMailboxURI ) , "Digest" , new
NetworkCredential ( strAlias , strPassword , strDomain ) );

#endregion

#region PUT Message
// Create the HttpWebRequest object.
PUTRequest = ( HttpWebRequest ) HttpWebRequest.Create ( strTempURI );

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

// Specify the PUT method.
PUTRequest.Method = "PUT";

// Encode the body using UTF-8.
bytes = Encoding.GetEncoding ( "iso-8859-9" ).GetBytes ( ( string )
strBody );

// Set the content header length. This must be
// done before writing data to the request stream.
PUTRequest.ContentLength = bytes.Length;

// Get a reference to the request stream.
PUTRequestStream = PUTRequest.GetRequestStream ( );

// Write the message body to the request stream.
PUTRequestStream.Write ( bytes , 0 , bytes.Length );

// Close the Stream object to release the connection
// for further use.
PUTRequestStream.Close ( );

// Set the Content-Type header to the RFC 822 message format.
PUTRequest.ContentType = "message/rfc822";

// PUT the message in the Drafts folder of the
// sender's mailbox.
PUTResponse = ( HttpWebResponse ) PUTRequest.GetResponse ( );
#endregion

When the cursor comes to the "PUTResponse = ( HttpWebResponse )
PUTRequest.GetResponse ( );" row while i am debugging, after executing, it
gives the 409 error.

I hope it helps you thanks...


"Henning Krause [MVP]" < XXXX@XXXXX.COM > wrote in
message news: XXXX@XXXXX.COM ...


 
 
 

409 conflict?

Post by Henning Kr » Wed, 10 May 2006 23:50:12

ello,

are you working on an english mailbox? The drafts folder is one of the
localized folders...

Greetings,
Henning Krause

"Adam Right" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

409 conflict?

Post by Adam Righ » Thu, 11 May 2006 00:59:55

i,

Yes i am working in english box. Is there solution for 409 conflict problem?


"Henning Krause [MVP]" < XXXX@XXXXX.COM > wrote in
message news: XXXX@XXXXX.COM ...


 
 
 

409 conflict?

Post by Henning Kr » Thu, 11 May 2006 03:54:52

ello,

are you sure, you are not uploading a file to an url already in use by
another item? Have you tried a different name?

From the MSDN documentaion:
"Cannot PUT a resource if all ancestors do not already exist. [WebDAV]
If versioning is being used and the entity being PUT includes changes to a
resource that conflict with those made by an earlier (third-party) request,
the server might use the 409 response code to indicate that it cannot
complete the request. [HTTP/1.1]"

Greetings,

Henning Krause


"Adam Right" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

409 conflict?

Post by Adam Righ » Fri, 12 May 2006 19:20:10

i,

I have tried to change the name of my mail while i was debugging the source
code , but it gave me the same error message. I have read MSDN documentation
that you have send in your mail but i cannot understand it much, because i
have not enough information about exchange server and [webdav], so i do not
know the terminology such as "PUT" or like that.

Can you explain me the case in MSDN documentation? According to the that
case, how can i check my code or exhange server configuration while i am
debugging my code to send an email? Thanks...

"Henning Krause [MVP]" < XXXX@XXXXX.COM > wrote in
message news: XXXX@XXXXX.COM ...