ImapClient.Search does not return all messages when called with parameter 'DateTime.MinValue'

+1 vote
asked Jan 10, 2014 by SeToY (520 points)
edited Jan 13, 2014

Hello,

I've experienced a discrepancy using the ImapClient.Search method. In the parameter, it states that I can use the 'Arrived' search even with a DateTime.MinValue value.

So, the following query returns '0' results

ImapMessageCollection msgCollection = imapClient.Search(
    ImapListFields.Envelope | ImapListFields.AttachmentInfo,
    ImapSearchParameter.Arrived(DateTime.MinValue, DateTime.Today));

while this query returns '2' results. Why is that?

ImapMessageCollection msgCollection = imapClient.Search(
    ImapListFields.Envelope | ImapListFields.AttachmentInfo, 
    ImapSearchParameter.All);
Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Jan 13, 2014 by Tomas Knopp (58,890 points)
edited Jan 13, 2014
 
Best answer

Hello,

please try this code instead:

        ImapMessageCollection msgCollection = client.Search(
            ImapListFields.Envelope | ImapListFields.AttachmentInfo,
            ImapSearchParameter.Arrived(DateTime.MinValue, DateTime.Today.AddDays(1)));

Does it help to check for the higher bound + 1 day as in my code above?

By the way what is the IMAP server you are connecting to? Thank you for your response.

commented Jan 13, 2014 by SeToY (520 points)
edited Jan 13, 2014

Hello,

this works, thank you. I'm connecting to hMailServer IMAP.

commented Jan 13, 2014 by Tomas Knopp (58,890 points)
edited Jan 13, 2014

I am glad the workaround has helped. Thank you for getting back to us.

...