How to Get all unread mails 开发者_高级运维from Exchange server 2007 using Exchange web service?
int unreadEmailCount = 0;
SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
ItemView view = new ItemView(999);
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, searchFilter, view);
unreadEmailCount = findResults.Items.Count;
Try the code below, click here to read more
static void Main(string[] args)
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new NetworkCredential("Active Dir ID", "password", "domain name");
service.AutodiscoverUrl("user@domain.com");
FindItemsResults<Item> findResults = service.FindItems(
WellKnownFolderName.Inbox,
new ItemView(10));
foreach (Item item in findResults.Items)
Console.WriteLine(item.Subject);
}
精彩评论