Использование 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);