0
EWS APIを使用して、以下のコードを使用してメールボックスから未読メッセージを取得します。会議出席依頼(または招待)も取得しています。これらのタイプの電子メールを無視する方法はありますか?EWS管理API - 会議出席依頼を無視する
//search filter to get unread email
var searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
//count of unread emails to retrieve
var view = new ItemView(50) { PropertySet = new PropertySet(PropertySet.IdOnly) };
//properties to return in the result set
var propertySet = new PropertySet {
ItemSchema.Subject,
ItemSchema.Body,
ItemSchema.HasAttachments,
ItemSchema.DateTimeReceived };
//order the search results by the DateTimeReceived in asc order
view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Ascending);
//set the traversal to shallow - shallow is the default option other options are Associated and SoftDeleted
FindItemsResults<Item> findResults;
do {
//get emails from Inbox using search filter, view and retrieve properties defined above
findResults = exchangeService.FindItems(WellKnownFolderName.Inbox, searchFilter, view);
if (findResults.Items.Count > 0)
{
//do stuff
}
view.Offset += findResults.Items.Count;
} while (findResults.MoreAvailable);
例を挙げることはできますか?クライアント側でどのようにフィルタリングしますか? – obautista
あなたが行う必要があるのは、ItemSchema.ItemClassをプロパティセットに追加し、次にItemClassプロパティの値を調べることで、扱うアイテムのタイプを判断するだけです。 EWS Managed APIでは、型付きアイテムも返されます。たとえば、(Item is EmailMessage)などのアイテムタイプをチェックするだけです(ミーティングの招待状はMeetingRequestになります)。コードを書くように人々に依頼する前に、まずそれを試してみてください。これは、あなたが書いたものがうまくいかなくても学ぶ方法です。 –