andyedinborough / aenetmail

C# POP/IMAP Mail Client
369 stars 153 forks source link

Some problem with filter #186

Open lexamad opened 8 years ago

lexamad commented 8 years ago

I have a problem with MS Exchange server imap filter conditions SentOn (and others with date)

when i try var msgs = imap.SearchMessages( SearchCondition.SentOn(new DateTime(2015, 09, 11)));

occurs error "xm004 BAD Command Argument Error. 11"

But this is example work with imap.gmail.com.

I found this article The SEARCH command (SENTSINCE, SINCE, SENTBEFORE, SENTON, BEFORE) works only with with a date, not a date + timestamp. http://stackoverflow.com/questions/22392120/python-imap-mail-seach-with-minutes

May be you change, for example here in AE.Net.Mail.SearchCondition
public override string ToString(){ .... if (value is DateTime) { if (Field.Equals(Fields.SentSince) || Field.Equals(Fields.Since) || Field.Equals(Fields.SentBefore) || Field.Equals(Fields.SentOn) || Field.Equals(Fields.Before) ) value = ((DateTime)value).ToString("dd-MMM-yyyy", _enUsCulture); else value = ((DateTime)value).GetRFC2060Date().QuoteString(); }

}

Thank you