开发者

How to Get all unread mails from Exchange server 2007 using Exchange web service?

开发者 https://www.devze.com 2022-12-30 10:41 出处:网络
How to Get all unread mails 开发者_高级运维from Exchange server 2007 using Exchange web service?int unreadEmailCount = 0;

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);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消