aenetmail
aenetmail copied to clipboard
Error searching for Gmail emails started "xm003 BAD Could not parse command"
Two days ago we started getting the following error when searching for emails after a particular date from a Gmail account:
xm003 BAD Could not parse command
at AE.Net.Mail.ImapClient.Search(String criteria, Boolean uid) in c:\Repos\aenetmail\ImapClient.cs:line 703
at AE.Net.Mail.ImapClient.Search(SearchCondition criteria, Boolean uid) in c:\Repos\aenetmail\ImapClient.cs:line 691
at ....
We didn't make any changes to the code. Anyone else start experiencing this when querying Gmail?
I am experiencing something very similar here, getting the exception below when searching for emails after a specific date using SearchCondition SentSince(datetime).
Stack Trace:
System.Exception: xm004 BAD Could not parse command at AE.Net.Mail.ImapClient.Search(String criteria, Boolean uid) at AE.Net.Mail.ImapClient.Search(SearchCondition criteria, Boolean uid) at ...
Also running into this - gmail only - other mail servers don't throw this Couldn't figure out what causes this but other mail libraries seem to be getting this aswell example: https://github.com/nikoblag/Gmail.ps/issues/14
We are experiencing the exact samme issue using the "Since" field on SearchCondition.
First I was able to prevent the error by setting the Value property of SearchCondition to a string with no time (instead of a DateTime):
SearchCondition condition = new SearchCondition(); condition.Field = SearchCondition.Fields.Since; condition.Value = new DateTime(2016, 10, 1).ToString("dd-MMM-yyyy");
Then 2-3 days later that solution stopped working. And now I am using one of Gmail's IMAP extensions:
SearchCondition condition = new SearchCondition(); condition.Value = string.Format(@"X-GM-RAW ""AFTER:{0:yyyy-MM-dd}""", new DateTime(2016, 10, 1));
Currently I am only using the library with Gmail - I don't think the above "fix" would work with other providers.
Thanks @ReneNP - That solution in a ternary will work for me If it's gmail use Gmail extension otherwise use regular search command
Would be nice to now why the regular search command no longer works with Gmail though
It looks like the issue is that GMail is no longer able to handle the SearchCondition.GetRFC2060Date format. See related Gmail help forum
Note* Per IMAP RFC 3501 & 2060 it looks like SentSince should be Date and not Date-Time So search is sending something like this:
SEARCH SENTSINCE "28-Oct-2016 13:55:27 -05"
but should be sending
SEARCH SENTSINCE "28-Oct-2016"
Any update on this issue. Facing the same problem with Gmail.