This project is read-only.

Search("SINCE " + DateTime.Now.ToString("dd-MMM-yyyy") Does not work correctly

Apr 18, 2014 at 7:58 AM
Hi Pavel,
I used Search("SINCE " + DateTime.Now.ToString("dd-MMM-yyyy") to get for today email but it does not return any email if I use Search("SINCE " + DateTime.Now.AddDays(-1).ToString("dd-MMM-yyyy") it returns email from yesterday until today which is not fine, what's wrong with that?


Apr 18, 2014 at 10:55 AM
Edited Apr 18, 2014 at 10:57 AM
Hi Ehsan,

the SINCE query is searching messages whose internal date (disregarding time and timezone) is within or later than the specified date. So the result you get is just fine. If you want to request the messages for today only, you can use the ON query:
client.Folders.Inbox.Search(string.Format("ON {0}", DateTime.Now.ToString("dd-MMM-yyyy", new CultureInfo("en-US"))))
This will return the messages whose internal date (disregarding time and timezone) is within the specified date. Please also consider setting the culture when formatting the date to en-US. Otherwise you might end up with a wrong formatted date.

You can also take a look at the specification, it contains the description of all standard search queries.