Search code examples
c#imapgmail-imap

IMAP Search Command with date filter


I am trying to get UID list of mails in a particular date range. Am trying to perform the below command

$ UID SEARCH SINCE 24-april-2017 BEFORE 27-april-2017 UID 1:*

Getting exception as BAD COMMAND.

Any suggestion?


Solution

  • The syntax for month is:

    date-month      = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" /
                      "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec"
    

    So your command ought to be

    $ uid search since 24-apr-2017 before 27-apr-2017 uid 1:*
    * SEARCH 317556 317557 [...] 318139 318140
    $ OK done
    

    Or just $ uid search since 24-apr-2017 before 27-apr-2017 since the UID restriction is a no-op.