我收到错误消息“远程服务器返回错误:(501)未实现。” 当我尝试使用 HttpWebRequest.GetResponse() 使用 GET 方法从交换中获取电子邮件附件时。我试图更改 HttpVersion 并且认为这不是权限问题,因为我可以搜索收件箱。
我知道我的凭据是正确的,因为它们用于使用 HttpWebRequest.Method = Search on the inbox ( https://mail.mailserver.com/exchange/testemailaccount/Inbox/ ) 获取 HREF。
HREF = https://mail.mailserver.com/exchange/testemailaccount/Inbox/testemail.EML/attachment.csv
示例代码:
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();
}
}