當我嘗試使用GET方法使用HttpWebRequest.GetResponse()獲取電子郵件附件時,出現錯誤消息「遠程服務器返回了錯誤:(501)Not Implemented來自交換。我試圖改變HttpVersion,並不認爲這是一個權限問題,因爲我可以搜索收件箱。無法從Exchange獲取電子郵件附件
我知道我的憑據是正確的,因爲它們用於使用收件箱中的HttpWebRequest.Method = Search(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();
}
}