Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1106265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:45:55+00:00 2026-05-17T01:45:55+00:00

I am having the following code to Save message to Exchange WEBDAV Drafts folder.

  • 0

I am having the following code to Save message to Exchange WEBDAV Drafts folder. IT saves the message but If open it in Outlook, Send button is Disabled and the message is readonly. Please help me find what am i missing in this code…

thanks
Bhuvan

 strBody = "To: " + strTo + "\n" +
                "Subject: " + (string.IsNullOrEmpty(message.Subject) ? "" : message.Subject) + "\n" +
            "Date: " + System.DateTime.Now + "\n" +
            "X-Mailer: test mailer" + "\n" +
            "MIME-Version: 1.0" + "\n" +
            "Content-Type: text/html;" + "\n" +
            "Charset = \"iso-8859-1\"" + "\n" +
            "Content-Transfer-Encoding: 8bit" + "\n" +
            "\n" + (string.IsNullOrEmpty(message.HtmlBody) ? "" : message.HtmlBody.Replace("<head />","").Replace("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",""));

            // Create the HttpWebRequest object.
            PUTRequest = (System.Net.HttpWebRequest)HttpWebRequest.Create(tgtUri);

            // Add the network credentials to the request.
            // Use default credentials of the service to access the server.
            PUTRequest.Credentials = cred;


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

            // Encode the body using UTF-8.
            byte[] bytes = Encoding.UTF8.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 = (System.Net.HttpWebResponse)PUTRequest.GetResponse();

            if (message.Attachments != null)
            {
                //Do the PROPPATCH
                System.Net.HttpWebRequest PROPPATCHRequest;
                System.Net.WebResponse PROPPATCHResponse;
                System.IO.Stream PROPPATCHRequestStream = null;

                string strxml = "<?xml version='1.0'?>" +
                "<d:propertyupdate xmlns:d='DAV:'>" +
                "<d:set>" +
                "<d:prop>" +
                "<isCollection xmlns='DAV:'>False</isCollection>" +
                "</d:prop>" +
                "</d:set>"
                + "<g:remove>"
                + "<g:prop><m:date/></g:prop>"
                + "</g:remove>" 
                + "</d:propertyupdate>";

                PROPPATCHRequest = (System.Net.HttpWebRequest)HttpWebRequest.Create(tgtUri);
                PROPPATCHRequest.Credentials = cred;
                PROPPATCHRequest.Headers.Set("Translate", "f");
                PROPPATCHRequest.ContentType = "text/xml";
                PROPPATCHRequest.ContentLength = strxml.Length;
                PROPPATCHRequest.Method = "PROPPATCH";
                byte[] PROPPATCHbytes = Encoding.UTF8.GetBytes(strxml);
                PROPPATCHRequest.ContentLength = PROPPATCHbytes.Length;
                PROPPATCHRequestStream = PROPPATCHRequest.GetRequestStream();
                PROPPATCHRequestStream.Write(PROPPATCHbytes, 0, PROPPATCHbytes.Length);
                PROPPATCHRequestStream.Close();
                PROPPATCHResponse = (System.Net.HttpWebResponse)PROPPATCHRequest.GetResponse();


                foreach (KeyValuePair<string, byte[]> attachment in message.Attachments)
                {
                    System.IO.Stream PUTAttachRequestStream = null;
                    System.Net.HttpWebRequest PUTAttachRequest;
                    System.Net.WebResponse PUTAttachResponse;
                    //Attach File: This could be put in a loop to attach more than one file.
                    string FileName = attachment.Key; //@"2842498_794802035296_Label1.pdf";
                    string attachURI = tgtUri + "/" + FileName;
                    PUTAttachRequest = (System.Net.HttpWebRequest)HttpWebRequest.Create(attachURI);
                    PUTAttachRequest.Credentials = cred;
                    PUTAttachRequest.Method = "PUT";

                    PUTAttachRequest.ContentLength = attachment.Value.Length; //binaryData.Length;
                    PUTAttachRequestStream = PUTAttachRequest.GetRequestStream();
                    PUTAttachRequestStream.Write(attachment.Value, 0, attachment.Value.Length); //(binaryData, 0, binaryData.Length);
                    PUTAttachRequestStream.Close();

                    PUTAttachResponse = (System.Net.HttpWebResponse)PUTAttachRequest.GetResponse();
                    PUTAttachResponse.Close();
                }

                PROPPATCHResponse.Close();
            }

            // Clean up.
            PUTResponse.Close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:45:55+00:00Added an answer on May 17, 2026 at 1:45 am

    I found the answer in Akash’s blog on msdn. One has to carefully read this to get the actual answer, but the solution worked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having following code but unable to understand as to why no match
I m having the following code, however, I can see that the radio button
I am having following code for getting image from the web: NSURL *ImageURL =
I am having the following code: public ActionResult EditTrain(EditTraing editrain) { .... .... return
I am having following peice of code ,where in i am trying to serialize
I'm having problems the following code gives me no results. however if I uncomment
Just wondering, having the following simple code: var object1 = { name: function (){
The following code is having some problem with the jQuery. <script type="text/javascript"> $(window).load(function() {
having a look at the following code: CCSprite* testsprite = [CCSprite spriteWithFile:@test.png]; CCLOG(@1. count:
Having sorted the tag_counts hash via the following code: sorted_tags = Contact.tag_counts.sort{ |x,y| x.name.downcase

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.