Flowdock
search(keys, charset = nil) public

Sends a SEARCH command to search the mailbox for messages that match the given searching criteria, and returns message sequence numbers. keys can either be a string holding the entire search string, or a single-dimension array of search keywords and arguments. The following are some common search criteria; see [IMAP] section 6.4.4 for a full list.

<message set>

a set of message sequence numbers. ‘,’ indicates an interval, ‘:’ indicates a range. For instance, ‘2,10:12,15’ means “2,10,11,12,15”.

BEFORE <date>

messages with an internal date strictly before <date>. The date argument has a format similar to 8-Aug-2002.

BODY <string>

messages that contain <string> within their body.

CC <string>

messages containing <string> in their CC field.

FROM <string>

messages that contain <string> in their FROM field.

NEW

messages with the Recent, but not the Seen, flag set.

NOT <search-key>

negate the following search key.

OR <search-key> <search-key>

“or” two search keys together.

ON <date>

messages with an internal date exactly equal to <date>, which has a format similar to 8-Aug-2002.

SINCE <date>

messages with an internal date on or after <date>.

SUBJECT <string>

messages with <string> in their subject.

TO <string>

messages with <string> in their TO field.

For example:

p imap.search(["SUBJECT", "hello", "NOT", "NEW"])
#=> [1, 6, 7, 8]
Show source
Register or log in to add new notes.