0
如何使用Exchange Web服務從Exchange Server 2007獲取所有未讀郵件?如何使用Exchange Web服務從Exchange Server 2007獲取所有未讀郵件?
如何使用Exchange Web服務從Exchange Server 2007獲取所有未讀郵件?如何使用Exchange Web服務從Exchange Server 2007獲取所有未讀郵件?
嘗試下面的代碼,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("[email protected]");
FindItemsResults<Item> findResults = service.FindItems(
WellKnownFolderName.Inbox,
new ItemView(10));
foreach (Item item in findResults.Items)
Console.WriteLine(item.Subject);
}
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;