This project is read-only.

Search query couldn't be processed

Topics: Help requests
Dec 19, 2013 at 2:28 PM
I'm not sure what I did. My program was running fine until I upgraded to the latest version (2.0.0.15) and now my search query comes back with "The search query couldn't be processed" error.

var query = string.Format("X-GM-RAW \"{0} -({1})\"",
                            string.Join(" OR ", senders.Select(sendername => "(from:" + sendername + ")").ToArray()),
                            string.Join(" OR ", excludedLabels.Select(label => "(label:" + label + ")").ToArray()));

                        messages = myInbox.Search(query, ImapX.Enums.MessageFetchMode.Basic | ImapX.Enums.MessageFetchMode.GMailExtendedData, 1000); 
STACKTRACE
at ImapX.Folder.SearchMessageIds(String query, Int32 count) in c:\Users\Pavel\Projects\ImapX\ImapX\Folder.cs:line 397
at ImapX.Folder.Search(String query, MessageFetchMode mode, Int32 count) in c:\Users\Pavel\Projects\ImapX\ImapX\Folder.cs:line 422
at ABSConsoleImport.Program.Main(String[] args) in c:\Users\Matt Taylor\Documents\Visual Studio 2012\Projects\ABSConsoleImport\ABSConsoleImport\Program.cs:line 61
Coordinator
Dec 20, 2013 at 11:15 AM
Hi maylortaylor,

please set client.IsDebug to true and post here the list of answers from the server which are shown in the console. This way I can give a more clear answer to your question or look for an issue.

Greets,

Pavel
Dec 20, 2013 at 2:26 PM
Ok, it's set to true, but how do I print it to the console? Is there a specific exception that I have to 'catch'?
Coordinator
Dec 20, 2013 at 8:11 PM
It should be logged within the debug output in Visual Studio automatically.
Dec 20, 2013 at 9:12 PM
pavel_azanov wrote:
It should be logged within the debug output in Visual Studio automatically.
annnnd I would print that out how?

I'm catching the exception with a try / catch. Would I use Debug.Write(ex.message) or something like that?

Sorry, other than Exception's - I'm clueless on debugging
Dec 20, 2013 at 9:20 PM
annnnd I would print that out how?
Just copy it from VS's Output window.

--Ravi
Coordinator
Dec 20, 2013 at 9:22 PM
Edited Dec 20, 2013 at 9:23 PM
I don't need the exception details, as I know where it occurs. More interesting is what happens before this exception. After setting client.IsDebug to true, all answers from the server (for all commands) will be logged in the debug output window in VS. So you just set IsDebug to true, and copy the output here.
Dec 20, 2013 at 9:29 PM
This is all I'm getting from the Immediate WIndow & Output window

A first chance exception of type 'System.ArgumentException' occurred in ImapX.dll
Dec 20, 2013 at 9:32 PM
Visual Studio > Tools> Options > Debugging > Output Window > and check the options for Output types.

--Ravi
Dec 20, 2013 at 9:47 PM
ravib wrote:
Visual Studio > Tools> Options > Debugging > Output Window > and check the options for Output types.

--Ravi
Every thing is checked in that screen. (MS Visual Studio 2012 btw) and still, this is all I'm getting in the output menu

The thread 'vshost.NotifyLoad' (0x3450) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x3444) has exited with code 0 (0x0).
'ABSConsoleImport.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Users\Matt Taylor\Documents\Visual Studio 2012\Projects\ABSConsoleImport\ABSConsoleImport\bin\Debug\ABSConsoleImport.exe', Symbols loaded.
'ABSConsoleImport.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Users\Matt Taylor\Documents\Visual Studio 2012\Projects\ABSConsoleImport\ABSConsoleImport\bin\Debug\ImapX.dll'
A first chance exception of type 'System.ArgumentException' occurred in ImapX.dll

Coordinator
Dec 20, 2013 at 9:55 PM
This is what it should look like:

Image
Dec 26, 2013 at 3:55 PM
Edited Dec 26, 2013 at 5:44 PM
I am getting the same error. I am not well versed in C# and I've just downloaded the newest version of ImapX 2, but when I search by subject this is what I'm getting at the end of the output window:

"A first chance exception of type 'System.ArgumentException' occurred in ImapX.dll"

And I get the "Additional information: The search query couldn't be processed".

When I search as "UNSEEN" it works fine, but not by subject. This is what my code looks like:

client.Behavior.MessageFetchMode = ImapX.Enums.MessageFetchMode.Basic;
var folder = client.Folders.Inbox;
var messages = folder.Search("SUBJECT Holiday cheer");

Seems it should be fairly straight-forward, but still.

EDIT: Woops, my bad. Keep forgetting that the string needs to be surrounded with quotes. So this worked fine:

var messages = folder.Search("SUBJECT \"Holiday cheer\"");

just notice the escaped quotation marks around the actual subject string.
Coordinator
Dec 26, 2013 at 8:46 PM
Hi deusdies,

yes, the problem is in the missing quotations.

maylortaylor: can you post here the complete query you're sending to the server? It might be same problem as deusdies had - missing quotes.

Best regards,

Pavel
Dec 26, 2013 at 9:12 PM
var query = string.Format("X-GM-RAW \"{0} -({1})\"",
                        string.Join(" OR ", senders.Select(sendername => "(from:" + sendername + ")").ToArray()),
                        string.Join(" OR ", excludedLabels.Select(label => "(label:" + label + ")").ToArray()));

                    messages = myInbox.Search(query, ImapX.Enums.MessageFetchMode.Basic | ImapX.Enums.MessageFetchMode.GMailExtendedData, 1000); 
query == X-GM-RAW "(from:Title Source Abstracting) OR (from:TSI Settlement Services) OR (from:PCN-ATTORNEY OPINION-WEST VIRGINIA) OR (from:iTitleHub) OR (from:Title Abstract) -((label:AWATSON Processed) OR (label:CRASHE Processed) OR (label:Duplicate) OR (label:GADAMS Processed) OR (label:RLEARN Processed) OR (label:RReed Processsed) OR (label:SLYONS Processed) OR (label:Manual) OR (label:Overdue) OR (label:Overdue Warning) OR (label:Import Success) OR (label:Research) OR (label:ATR Research))"
Jan 6, 2014 at 3:01 PM
Edited Jan 6, 2014 at 3:18 PM
Just saw this after installing VS2013

"'ABSConsoleImport.vshost.exe' (CLR v2.0.50727: ABSConsoleImport.vshost.exe): Loaded 'C:\Users\Matt Taylor\Documents\Visual Studio 2012\Projects\ABSConsoleImport\ABSConsoleImport\bin\Debug\ImapX.dll'. Cannot find or open the PDB file.
A first chance exception of type 'System.ArgumentException' occurred in ImapX.dll"

1) ImapX works just fine if I use "ALL" as the search query >>> leading me to believe it has to be something wrong with my query in the above post
2) would the NOT work if let's say the email address I am searching through does not contain any of the "FROMS" or "LABELS" I am specifically searching for? So, in my query above, if the email address didn't contain any "From: Title Source Abstracting" would it cause this error?
Coordinator
Jan 6, 2014 at 7:50 PM
Edited Jan 6, 2014 at 7:50 PM
Hi maylortaylor,

i have tested your query:
query == X-GM-RAW "(from:Title Source Abstracting) OR (from:TSI Settlement Services) OR (from:PCN-ATTORNEY OPINION-WEST VIRGINIA) OR (from:iTitleHub) OR (from:Title Abstract) -((label:AWATSON Processed) OR (label:CRASHE Processed) OR (label:Duplicate) OR (label:GADAMS Processed) OR (label:RLEARN Processed) OR (label:RReed Processsed) OR (label:SLYONS Processed) OR (label:Manual) OR (label:Overdue) OR (label:Overdue Warning) OR (label:Import Success) OR (label:Research) OR (label:ATR Research))"
and it runs just fine for me:

Image

(The UID SEARCH is being appended automatically when you use the Folder.Search method)

To your last questions:

The result of the query does not depend on how many or if any messages were found. If no messages match the query, simply an OK with no uids is being returned.

Greets,

Pavel