2017-05-11 6 views
0

EWS API를 사용하여 아래 코드를 사용하여 사서함에서 읽지 않은 메시지를 검색합니다. 모임 요청 (또는 초대)도 검색하고 있습니다. 이러한 유형의 이메일을 무시할 수있는 방법이 있습니까?EWS Managed 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); 

답변

0

회의 요청은 당신도 단지 (내가 무엇을 할 것이라고입니다) 클라이언트 측에서이를 필터링 할 수 있도록 다른과 itemClass이 있거나 그러나 (단지 IPF.Note의 itemClass 속으로 항목을 반환하는 SearchFilter을 만듭니다 이런 식으로 몇 가지 항목을 놓칠 수 있습니다.)

+0

예제를 제공해 줄 수 있습니까? 클라이언트 측에서 어떻게 필터링합니까? – obautista

+0

당신이해야 할 일은 속성 집합에 ItemSchema.ItemClass를 추가하고 ItemClass 속성의 값을 살펴서 처리 할 항목의 유형을 결정하기 만하면됩니다. 또한 EWS Managed API는 입력 된 항목을 반환하므로 항목 유형 (예 : 항목이 EmailMessage) 등을 확인하는 것이 좋습니다 (회의 초대는 MeetingRequest가됩니다). 사람들에게 코드를 작성하도록 요청하기 전에 먼저 직접 시도해야합니다. 작성한 코드가 작동하지 않더라도 배울 수 있습니다. –