MailQuery using today as SentDate not correctly filtering messages and always returning 0 messages


I am having problems filtering emails using today’s date. I have an IMAP configuration in a VB.Net environment using the MailQueryBuilder to pass through a MailQuery to BeginListMessages.

I have tried various forms of internaldate or sentdate to filter messages received today. But 0 messages are returned.

I have tried the following options:


I have also tried using InternalDate instead of SentDate. Whatever I use, 0 messages are returned, when I know emails have been sent on “today’s” date.

Is the SentDate time specific? Am I using the correct querybuilder syntax?



Thank you for writing to Aspose support team.

Could you please share with us which version of Aspose.Email for .NET you are using? I have tested this issue with the latest version of Aspose.Email for .NET 3.9.0 and was unable to observe it at my end using the following sample code. Please try it with this latest version and if the issue still exists, please share the sample code for investigation at our end. We’ll look into it for further assistance.

Sample Code:

static async void ImapAsyncListMsgs(Object o)
    scanTimer.Change(Timeout.Infinite, Timeout.Infinite);

    ImapQueryBuilder builder = new ImapQueryBuilder();
    MailQuery query = builder.GetQuery();

    ImapMessageInfoCollection msgs = await Task<ImapMessageInfoCollection>.Factory.FromAsync(imap.BeginListMessages(query), imap.EndListMessages);

    foreach (ImapMessageInfo msgInfo in msgs)


I am using the latest version of 3.9.0.

I have provided sample code showing the various forms of using the querybuilder.SentDate.On criteria.

The example you provided me shows the SentDate.Since criteria not SentDate.On criteria. Since criteria appears to be working for me, its just the On criteria I am having problems with. I am connecting to a gmail mailbox.

Can you please provide me with a working example using the SentDate.On criteria?

Thank you.

Thank you for writing back to us.

I have re-investigated this issue with the SentDate.On criteria over a Gmail account and I still get the valid number of emails in the mailbox. Please have a look at the attached screenshot here for your kind reference. I would also like to add that "DateTime.Now" returns time with details upto the minute and seconds level of time and searching for a mail with this condition may not return the results as desired. With DateTime.Today, the code sample I have provided earlier works with SentDate.On criteria. Please give it a try at your end and lets us know your feedback.


I have done some further investigation. I have an email in my gmail inbox that is dated 16/3/2014 7:45AM (Australian Eastern Standard Time). When I read this email through the aspose interface client.BeginListMessages the date on the ImapMessageInfo.Date attribute shows the date as being 15/3/2014 9:45:09PM. I assume that the date of the message returned via aspose is the date in terms of greenwich meantime as Australian time is GMT + 10 hours.

Can you please explain to me how I am meant to apply criteria (ie as per my timezone, or as greenwich meantime?

Can Aspose handle my regional timezone setting so that the messages retrieved are with respect to my timezone setting?



Thank you for providing the additional information.

The list of messages retrieved are based on GMT time as I have observed during my analysis. I am afraid to share that there is no such option of specifying timezone setting while retrieving the list of messages. I have requested our development team about possibility of any such implementation and will update you here once the feedback is available in this regard.


I am trying to understand how the querying and criteria work with regard to GMT.

I have 3 emails which are retrieved using the aspose list of messages functionality. I have specified SentDate.On criteria to bring me back emails on the 18/3/2014.

The emails returned have the following GMT times.

GMT Time My mailbox time shows the email date time as (ie (UTC+10:00) Brisbane)
18/3/2014 10:23:36AM 18/3/2014 8:23:36PM
19/3/2014 5:06:46AM 19/3/2014 3:06:46PM
19/3/2014 5:39:39AM 19/3/2014 3:39:39PM

Can you please explain why I am getting emails returned on both the 18th and the 19th?
Thank you.


Thank you for contacting support again.

I have analyzed your observations using my own account and found that behavior is apparently different than the expected one. I have logged an investigation ticket under id:NETWORKNET-34321 for the developers who will investigate this issue and will share their findings. I will write back here as soon as some feedback is received from the developers.

We have thoroughly investigated the issue and analyzed the command sent by Aspose.Email for extracting the mails based on InternalDate. It is observed that our library has implemented the search operation properly as it sends the right command say 008 SEARCH ON 6-Mar-2014 as mentioned in [IMAP Protocol]( As it is absolutely correct command sent by Aspose.Email and still server does not return all messages, the probable reason can be the server timezone settings because it is not always UTC e.g. GMAIL.

Aspose.Email has provided ImapMessageInfo.InternalDate for providing further control over mail extraction. You may please download the latest version of Aspose.Email for .NET 4.1.0 and use this newly added property as given here .

Please feel free to write us back if you have any pother query related to Aspose.Email.