We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Reading only UnRead messages from Exchange Server


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();


MailQuery query = build.GetQuery();

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

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