Question about Search Queries

May 6, 2013 at 2:40 PM
I've just seen this project and it seems to be great.
But I've runned into a problem when trying to perform SearchMessage.
I want to search by sender and date.
So I call SearchMessage in the following way
String dts = DateTime.Now.Subtract(new TimeSpan(6, 0, 0)).ToString("d-MMM-yyyy", CultureInfo.InvariantCulture);
String searchQuery = String.Format("FROM \"{0}\" SINCE {1}", senderToSearch, dts);
MessageCollection msgcoll = imap.SearchMessage(searchQuery);
The resulting search query is
"UID SEARCH FROM \"\" SINCE 6-May-2013\r\n"

But this alway results in an exception "Bad Search Command".
But this search command should work becaus in my rather crude own attempts to access IMAP I've already tested it and it delivered results.

There I build the command this way:
String.Format("$ SEARCH FROM \"{0}\" SINCE {1}", sender,dts)
Any Idea what I've done wrong when trying it with ImapX?


May 6, 2013 at 2:54 PM
I found the solution already. Sorry to have bothered you.
You have to use the Class ImapClient instead Imap and then start the search through the folder collection. Then it is working.


May 6, 2013 at 4:53 PM
Hi Markus,

yes, the Imap class is only for internal use and will be removed in the next releases, so prefer ImapClient for all operations.

Best regards,

Pavel Azanov