Trouble getting email attachment from Exchange
Posted
by JimR
on Stack Overflow
See other posts from Stack Overflow
or by JimR
Published on 2010-04-15T20:53:18Z
Indexed on
2010/04/15
21:23 UTC
Read the original article
Hit count: 257
I am getting the error message “The remote server returned an error: (501) Not Implemented.” when I try to use the HttpWebRequest.GetResponse() using the GET Method to get an email attachment from exchange. I have tried to change the HttpVersion and don’t think it is a permissions issue since I can search the inbox.
I know my credentials are correct as they are used to get HREF using the HttpWebRequest.Method = Search on the inbox (https://mail.mailserver.com/exchange/testemailaccount/Inbox/).
HREF = https://mail.mailserver.com/exchange/testemailaccount/Inbox/testemail.EML/attachment.csv
Sample Code:
HttpWebRequest req = (System.Net.HttpWebRequest) HttpWebRequest.CreateHREF);
req.Method = "GET";
req.Credentials = this.mCredentialCache;
string data = string.Empty;
using (WebResponse resp = req.GetResponse())
{
Encoding enc = Encoding.Default;
if (resp == null)
{
throw new Exception("Response contains no information.");
}
using (StreamReader sr = new StreamReader(resp.GetResponseStream(), Encoding.ASCII))
{
data = sr.ReadToEnd();
}
}
© Stack Overflow or respective owner