2
我的目標是獲取給定文件夾中的所有電子郵件,但我不斷收到房產錯誤:EWS託管API獲取所有電子郵件項目出錯
The property Body can't be used in FindItem requests
請問你一些仁慈地指出我是什麼做錯了。以下是我使用.NET Framework 4.0的測試代碼:
private static void GetEmailMessageCollection(ExchangeService service)
{
ItemView view = new ItemView(100);
view.PropertySet = new PropertySet(PropertySet.FirstClassProperties);
view.PropertySet.Add(ItemSchema.HasAttachments);
view.PropertySet.Add(ItemSchema.Body);
view.PropertySet.Add(ItemSchema.DisplayTo);
view.PropertySet.Add(ItemSchema.IsDraft);
view.PropertySet.Add(ItemSchema.DateTimeCreated);
view.PropertySet.Add(ItemSchema.DateTimeReceived);
FindItemsResults<Item> findResults;
List<EmailMessage> emails = new List<EmailMessage>();
string archiveFolderID = " AQEuAAADGF6AegrId0+ekrWv0TJZtgEAZ2jpm1niGUS/jwC23X6j/AAAAgP/AAAA";
SearchFilter unreadSearchFilter = new SearchFilter.SearchFilterCollection();
Folder boundFolder = Folder.Bind(service, archiveFolderID);
findResults = boundFolder.FindItems(unreadSearchFilter, view);
foreach (var item in findResults.Items)
{
emails.Add((EmailMessage)item);
}
}
謝謝。
,如果你需要使用身體作爲過濾器你會怎麼做? I.E.在調用FindItems之前,需要正文值。我在[MSDN]上問你這個問題(https://social.msdn.microsoft.com/Forums/office/en-US/bdbfa8fa-43c2-4078-b13b-9795b1c8af0d/exchange-web-service-2007-sp1 -the-property-body-cant-be-used-in-finditem-requests?forum = exchangevrdevelopment)包括我的代碼片段。如果你能看一看,我會很感激。 – MadDev 2017-01-05 09:16:58