Message searching
Instead of listing all messages, there is a possibility to search only for messages by the specific criteria. The list of supported
criteria by Mailio is represented by imap::search_condition_t::key_type
. The associated value can be one of
the following in imap::search_condition_t::value_type
. With that in mind, each crieria is constructed by
giving the key and the value to the imap::search_condition_t
's constructor. The method
imap::search
takes list of conditions by applying the AND
logical
operator. The result of the messages is stored into a list of message ids given as the second parameter to the method. There is also the
third argument of the imap::search
as the flag, which specifies whether the messages are searched by sequence
or unique ids.
To find all messages before June 22nd 2018 with the subject "mailio", one should execute
list<unsigned long> messages;
list<imaps::search_condition_t> conds;
conds.push_back(imaps::search_condition_t(imaps::search_condition_t::BEFORE_DATE, boost::gregorian::date(2018, 6, 22)));
conds.push_back(imaps::search_condition_t(imaps::search_condition_t::SUBJECT, "mailio"));
conn.search(conds, messages, true);
The resulting list of messages will keep unique message ids.