Free Support Forum - aspose.com

MailQueryBuilder issue with date and Imap

Hi,

I’m trying to use MailQueryBuilder with IMAP server. My query is very simple:

Dim builder As MailQueryBuilder = New MailQueryBuilder()
builder.InternalDate.Before(DateTime.Now, DateComparisonType.ByDateTime)
builder.InternalDate.Since(DateTime.Now.AddMinutes(-30, DateComparisonType.ByDateTime)

In the last few days, the query it seemed to work fine. Today I sent a test email and this email it’s not returned by the query.

If I check the date in the headers of the message I see this value:

- 29 May 2015 13:54:34 +0000

If i check the header of the message in my webmail I see this value:

- 29 May 2015 13:54:34 +0200


If I fetch the message with the following code I obtain the correct date (29/05/2015 15.54.34):

imap.SelectFolder(ImapFolderInfo.InBox)
Dim messages = imap.ListMessages

Dim msg = imap.FetchMessage(messages(messages.Count - 1).UniqueId)
Dim msgDate = testMsg.Date + testMsg.TimeZoneOffset

So I cannot use the MailQueryBuilder because the query doesn’t retrieve all the messages correctly. There are already reports about it? It 'something that you are correcting? I know the for the POP3 the MailQueryBuilder should be fixed. It’s so for the IMAP?

Thanks,
Alessandro

Hi Alessandro,


Thank you for contacting the Aspose support team.

I have tested the scenario and have fetched the last half hour mail using the following sample code. Time since and before are set in UTC time and query is build upon this criteria. Could you please test the scenario using following code and share your feedback?

TimeZone localZone = TimeZone.CurrentTimeZone;<o:p></o:p>

TimeSpan ts = localZone.GetUtcOffset(DateTime.Now);

MailQueryBuilder builder = new MailQueryBuilder();

DateTime before = DateTime.Now - ts;

DateTime since = DateTime.Now.AddMinutes(-30) - ts;

builder.InternalDate.Before(before, DateComparisonType.ByDateTime);

builder.InternalDate.Since(since, DateComparisonType.ByDateTime);

ImapClient client = new ImapClient("imap.gmail.com", 993, "username", "password");

client.SecurityOptions = SecurityOptions.Auto;

client.SelectFolder("Inbox");

ImapMessageInfoCollection messages = client.ListMessages(builder.GetQuery());

foreach(ImapMessageInfo info in messages)

{

MailMessage mail = client.FetchMessage(info.UniqueId);

Console.WriteLine(mail.Subject);

}

Hello,

I’ve tried your example but doesn’t work in my scenario.
If I don’t provide the before value for the MailQueryBuilder, the query works and the message is retrieved correctly.
In my current application the before value is not so important, since it is always set to now. In general, however, I think there is a problem in the query when you specify the Before value.

Alessandro

Hi Alessandro,


I have observed the issue with “InternalDate.Before” and have logged it as EMAILNET-34808 in our bug tracking system for further analysis byt he product team.

An exception is also observed if we use “InternalDate.BeforeOrEqual” and have logged it as EMAILNET-34809 in bug tracking system.

I shall write here as soon as some feedback is received in this regard

The issues you have found earlier (filed as EMAILNET-34809) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.