karastojko / mailio

mailio is a cross platform C++ library for MIME format and SMTP, POP3 and IMAP protocols. It is based on standard C++ 17 and Boost library.
Other
374 stars 98 forks source link

Question about ranges (imap::messages_range_t) #121

Closed gekrap closed 1 year ago

gekrap commented 1 year ago

Is there a possibility to have a range of imap::messages_range_t include the maximum sequence number without having to know it? RFC9051 allows the special character "*" for this case. Can I use this via mailio?

karastojko commented 1 year ago

I believe this solves your problem:

imaps conn("xxx", 993);
conn.authenticate("xxx", "xxx", imaps::auth_method_t::LOGIN);
conn.select(list<string>({"Inbox"}));
list<unsigned long> messages;
conn.search(list<imap::search_condition_t>({imap::search_condition_t(imap::search_condition_t::SID_LIST, list<imap::messages_range_t>{make_pair(100, std::nullopt)})}), messages, true);

Note the nullopt for the criteria you have asked.

gekrap commented 1 year ago

Yes, this solves my question, thank you.