Open swhitlock opened 11 years ago
In the routine ImapClient.Search(string criteria, bool uid = true), I put this hack in just to test:
string command = tag + isuid + "SEARCH " + criteria;
command = command.Replace("\"21-Sep-2012 12:00:00 -04\"", "\"21-Sep-2012\""); // HACK
string response = SendCommandGetResponse(command);
When I did that, it seemed to work correctly.
I did find one likely bug, though fixing it doesn't fix this problem I'm having. Here's the current GetRFC2060Date function:
internal static string GetRFC2060Date(this DateTime date) {
return date.ToString("dd-MMM-yyyy hh:mm:ss zz", _enUsCulture);
}
Note that the "hh" used for displaying the Hour only gives you "The hour, using a 12-hour clock from 01 to 12.". The correct format string should use "HH": "The hour, using a 24-hour clock from 00 to 23.".
According to RFC3501 section 6.4.4:
SENTBEFORE <date>
Messages whose [RFC-2822] Date: header (disregarding time and
timezone) is earlier than the specified date.
So it looks to me like some IMAP servers (likely GMail's) just ignore the time and timezone but Exchange 2003's IMAP4 server chokes on it. In light of this, I suggest the new GetRFC2060Date function should be:
internal static string GetRFC2060Date(this DateTime date) {
return date.ToString("dd-MMM-yyyy", _enUsCulture);
}
It seems to work for me.
Ah yes, the hh
is a typo. Also, it seems like it should be return date.ToUniversalTime().ToString("dd-MMM-yyyy HH:mm:ss", _enUsCulture);
Would that work? Could you send me a pull request?
I tried without the time zone (-04) and that didn't work either. The only thing I can get to work is just the date.
I don't actually have git installed, just downloaded the zip and ran it/played with it. I initially had the NuGet package.
Try it with +0000 for the timezone?
Sent from my iPhone
On Nov 21, 2012, at 1:49 PM, "swhitlock" notifications@github.com<mailto:notifications@github.com> wrote:
I tried without the time zone (-04) and that didn't work either. The only thing I can get to work is just the date.
I don't actually have git installed, just downloaded the zip and ran it/played with it.
— Reply to this email directly or view it on GitHubhttps://github.com/andyedinborough/aenetmail/issues/109#issuecomment-10611589.
That didn't work:
xm004 UID SEARCH SENTBEFORE "21-Sep-2012 00:00:00 +0000"
xm004 BAD Protocol Error: "Invalid key supplied in the SEARCH command".
Neither did:
xm004 UID SEARCH SENTBEFORE "21-Sep-2012 00:00:00 -04:00"
xm004 BAD Protocol Error: "Invalid key supplied in the SEARCH command".
Here's the search criteria I'm using:
Here is the command sent to the server:
Here is the response:
Here's a full post of the entire exchange: