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

Free Support Forum - aspose.com

ExchangeQueryBuilder InternalDate DateTime Problem

Hello Aspose team,

Using exchange mail 2013, Aspose.Mail.dll version
I am facing the following problem with datetime stamp.

I have a mail box with number of mails received in 01/01/2017
I would like to ListMessages only between 01/01/2017 14:00 and 01/01/2017 14:30.

I use following code to create MailQuery:

pToDate = new DateTime(01/01/2017 14:30);
pFromDate= new DateTime( 01/01/2017 14:00);

ExchangeQueryBuilder qb = new ExchangeQueryBuilder();
MailQuery mq = qb.GetQuery();

As a result if this code I have mq = {((‘InternalDate’ <= ‘1-Jan-2017’)&(‘InternalDate’ >= ‘1-Jan-2017’))}
When I use this query with IEWSClient.ListMessages I have unexpected result (all mails from 1 Jan returned instead of requested time slice).
Please help me to resolve this issue
Thanks a lot

Hi George,

Thank you for contacting Aspose support team.

You may please use DateComparisonType to achieve the required output as follows:

ExchangeQueryBuilder qb = new ExchangeQueryBuilder();<o:p></o:p>

qb.InternalDate.BeforeOrEqual(pToDate, DateComparisonType.ByDateTime);

qb.InternalDate.Since(pFromDate, DateComparisonType.ByDateTime);

Hi Kashif,

Thanks a lot for help,
Works perfect.

You are welcome.