如何使用Exchange网络服务从Exchange Server 2007获取所有未读邮件?
答案 0 :(得分:6)
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;
答案 1 :(得分:0)
尝试以下代码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);
}