Question : .Net C# Getting the error: The remote server returned an error: (401) Unauthorized.  when using OWA Outlook Web Access

I am using the following code in C# .Net to access OWA (outlook web server)

I am able to go to the url using the username and password to access OWA, but when I try using the code below I receive the error.  The remote server returned an error: (401) Unauthorized.  

 System.Net.HttpWebRequest Request;
                System.Net.WebResponse Response;
                System.Net.CredentialCache MyCredentialCache;
                string strSourceURI = "https://webmail.datacert.com/exchange/";//"URL to my email object testing.eml";
                string strUserName = "username";
                string strPassword = "password";
            string strDomain = "domainname";
                MyCredentialCache = new System.Net.CredentialCache();

                MyCredentialCache.Add(new System.Uri(strSourceURI),
                   "NTLM",new System.Net.NetworkCredential(strUserName, strPassword, strDomain) );

                // Create the HttpWebRequest object.
                Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(strSourceURI);
                // Add the network credentials to the request.
                Request.Credentials = MyCredentialCache;
                // Specify the SEARCH method.
                Request.Method = "SEARCH";
                // Send the DELETE method request.
                Response = (System.Net.HttpWebResponse)Request.GetResponse();

Answer : .Net C# Getting the error: The remote server returned an error: (401) Unauthorized.  when using OWA Outlook Web Access

Here are some protocols to consider. Still don't know what you are trying to do or I would provide links to some examples.

CDO
WEBDAV
MAPI
Random Solutions  
 
programming4us programming4us