Need to filter mails based on date and time

HI,

I need to filter emails from the mailbox based on date and time. Currently i am able to filter the mails based on Date. Is there any way to filter the mails based on Date and time using mailquery.

Aspose.Email.MailQueryBuilder mailQueryBuilder = new Aspose.Email.MailQueryBuilder();

mailQueryBuilder.InternalDate.Before((DateTime.Now.AddHours(Convert.ToInt32(ArchiveValue))));

Aspose.Email.MailQuery mailQuery = mailQueryBuilder.GetQuery();

msgCollection = client.ListMessages
(client.GetMailboxInfo().DeletedItemsUri,mailQuery,false );

Thanks & Regards,

Hi Anish,


Thank you for contacting Aspose support.

Currently MailQuery filters mails based upon dates only. I have logged an enhancement ticket to provide feature for filtering mails based upon date and time both. This enhancement ticket is logged under id:NETWORKNET-34492 in our issue tracking system and I will write back here as soon as some feedback is received in this regard.

Hi Anish,


Thank you for contacting Aspose support.

I have checked the status of this ticket and glad to share that this issue is resolved and resolution will be available in the incoming release in the first week of October, 2014.

Please feel free to write us back if you have any other query in this regard.


Does this issue resolved. if resolved Could you please let me know the version of the dll.

Please provide a sample code to delete the set of emails based on time

Hi Anish,

Please try it with the latest version of Aspose.Email for .NET 5.1.0 and the following sample code. The DateComparisonType.ByDateTime argument allows you to search messages by Date time.

Sample Code:


MailQueryBuilder mailQueryBuilder = new MailQueryBuilder();

mailQueryBuilder.InternalDate.On(dt.AddHours(5), DateComparisonType.ByDateTime);

Could you please let me know the version of the jar in java. and please help me with Sample code .
MailQueryBuilder builder = new MailQueryBuilder();
builder.getInternalDate().beforeOrEqual(toDate);
builder.getInternalDate().since(fromDate);
query = builder.getQuery();

Hello @deepakkalal,

Thank you for writing to Aspose suppport .

The version of the jar depends on which version of Aspose.Email for Java you are using. You can check the version of the jar file by looking at its filename or by checking the MANIFEST.MF file inside the jar.

Here’s a sample code that filters mails based on Date and Time using MailQueryBuilder:

MailQueryBuilder builder = new MailQueryBuilder();
builder.getInternalDate().beforeOrEqual(toDate);
builder.getInternalDate().since(fromDate);
query = builder.getQuery();

Can you please clarify what problems you have using this code?

hi margarita
the problem i am facing with the above code is that it is not able to filter on the basis of both time* and date. It filters mails only on the basis of date. and i am using the latest version of Aspose.Email jar.

@deepakkalal,

We have opened the following new ticket.

Issue ID(s): EMAILJAVA-35159

@deepakkalal,

Could you check the below code for Date and Time comparison:

MailQueryBuilder builder = new MailQueryBuilder();
builder.getInternalDate().beforeOrEqual(toDate, DateComparisonType.ByDateTime);
builder.getInternalDate().since(fromDate, DateComparisonType.ByDateTime);
MailQuery query = builder.getQuery();
System.out.println(query.getQueryString());