Reading only UnRead messages from Exchange Server

Hi,

I was wondering if there is some method to retrieve only unread emails from Exchange server?

Hi Aaron,

Thank you for writing to Aspose support again.

ExchangeQueryBuilder is used for creating a filter for extracting messages from exchange server. Could you please give a try to the following sample code and let us know the feedback?

IEWSClient client = EWSClient.GetEWSClient(“https://outlook.office365.com/ews/exchange.asmx”, “user”, “password”, “”);

ExchangeMailboxInfo exchangeMailboxInfo = client.GetMailboxInfo();

ExchangeQueryBuilder build = new ExchangeQueryBuilder();

build.HasNoFlags(ExchangeMessageFlag.IsRead);

MailQuery query = build.GetQuery();

ExchangeMessageInfoCollection mic = client.ListMessages(exchangeMailboxInfo.InboxUri, query, true);

mic = client.ListMessages(exchangeMailboxInfo.InboxUri, query, false);