Filtering emails from mailbox between a specified time

Hi,

I am looking to test my application that fetches mails from a mailbox. I want to get all the mails sent in the last hour or any two time ranges. Following is how I build my query:
ExchangeQueryBuilder builder = new ExchangeQueryBuilder();
builder.InternalDate.Since(from);
builder.InternalDate.BeforeOrEqual(to);
MailQuery query = builder.GetQuery();

Now from and to are DateTime variables with an example say {08/08/18 06:47:22 AM} and {08/08/18 07:47:22 AM}. But when the query builds, it is:
((‘InternalDate’ >= ‘8-Aug-2018’)&(‘InternalDate’ <= ‘8-Aug-2018’))

The time information is stripped! How to fetch emails between that time range??

@sin2akshay,

Thank you for contacting Aspose support team.

You may please give a try to the following sample code and share the feedback.

ExchangeQueryBuilder builder = new ExchangeQueryBuilder();
builder.InternalDate.Since(DateTime.Now.AddDays(-1),DateComparisonType.ByDateTime);
builder.InternalDate.BeforeOrEqual(DateTime.Now, DateComparisonType.ByDateTime);
MailQuery query = builder.GetQuery();

Thanks for the solution and the early response, the overload works correctly. None of your Github Examples on query show this, they only have the day examples. Please include such example in your Github Samples as well.

@sin2akshay,

It’s good to know that the suggested code sample was of help to you. We’ll surely consider your suggestion for adding the sample code to GitHub examples as well.