+1 vote
by (520 points)
edited

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
by (58.9k points)
edited
 
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.

by (520 points)
edited

Hello,

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

by (58.9k points)
edited

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

...