3
我目前在Outlook 2010上使用EWS。我試圖根據類別字段來查找用戶的聯繫人。我基本上想要返回其類別字段包含特定子字符串的每個聯繫人。下面是一個例子:在列表屬性上使用SearchFilter
ExchangeService service = new ExchangeService
{
Credentials = new WebCredentials(user, password, domain),
Url = new Uri(exchangeUrl),
};
string searchString = "abc";
SearchFilter filter = new SearchFilter.ContainsSubstring(ItemSchema.Categories, searchString);
ItemView view = new ItemView(200);
Mailbox mailbox = new Mailbox("[email protected]");
FolderId folderId = new FolderId(WellKnownFolderName.Contacts, mailbox);
FindItemsResults<Item> results = service.FindItems(folderId, filter, view);
當然這失敗,因爲分類場現在是一個煩人的StringList
而不是一個普通的字符串。我們所有的用戶聯繫人都只有一個類別與其關聯。有沒有一種方法,我可以得到這個SearchFilter
工作,只能運行第一個類別比較?
請注意:由於我無法控制的原因,我cannot use AQS strings。他們根本不是一種選擇。我必須使用SearchFilter
對象(或某些其他機制來篩選結果)。
這是唯一的選擇...... ews API在某些領域真的很缺乏 – Reimius