The pure translator behind ImapCon$query(): it takes an ordinary R expression and returns the RFC 3501 search string it stands for, without touching any server. Fields are subject, from, to, cc, bcc, body, text (compared with == and !=, meaning contains and does not contain), flag (==/!= against system flags or custom keywords), size in bytes and age in seconds (>, >=, <, <=), the date fields sent, date (internal date), and saved (SAVEDATE servers), and header("Name"). Date fields accept "YYYY-MM-DD", "DD-Mon-YYYY", or Date values with >=, >, <, <=, and ==. Comparisons are combined with &, |, !, %in% (one field against several values), and parentheses; a bare string next to | or & inherits the field of the preceding comparison. Any other call, such as a criterion constructor like string(), is evaluated in the caller's environment and used as is.

imap_query(expr)

Arguments

expr

An unquoted expression, e.g. (subject == "budget" | "budget 3") & flag != "SEEN".

Value

The translated search string, of class "imap_search".

Examples

imap_query((subject == "budget" | "budget 3") & flag != "SEEN")
#> <imap_search> ((OR (SUBJECT "budget") (SUBJECT "budget 3")) (UNSEEN))
imap_query(sent >= "2001-10-01" & size > 5e6)
#> <imap_search> ((SENTSINCE 1-Oct-2001) (LARGER 5000000))
imap_query(subject %in% c("budget", "forecast") & age < 86400)
#> <imap_search> ((OR (SUBJECT "budget") (SUBJECT "forecast")) (YOUNGER 86400))