Mailbox statistics
As with POP3, it is possible to get the mailbox statistics. There is a structure of the same name as in POP3 —
imap::mailbox_stat_t
, but with more information: number of messages in a mailbox, number of recent and unseen
messages, unique identifier data. The statistics can be asked for any mailbox, not only the selected one and it can time consuming. For
that reason, there is the bitmask imap::mailbox_stat_t::stat_info_t
which specifies what kind of data will be
requested.
The method imap::statistics
has two overloads: one for the mailbox name as string and the other as
list of strings.
try
{
imap conn("imap.server.com", 143);
conn.authenticate("mailio@server.com", "mailiopass", imap::auth_method_t::LOGIN);
imaps::mailbox_stat_t stat1 = conn.statistics("Inbox/Archive/Development");
imaps::mailbox_stat_t stat2 = conn.statistics(list<string>{"Inbox", "Archive", "Development"});
}
catch (imap_error& exc)
{
cout << exc.what() << endl;
}
catch (dialog_error& exc)
{
cout << exc.what() << endl;
}
The second argument of the method imap::statistics
is the bitmask to determine whether the mailbox should be
queried only for basic info, or the additional information like unseen messages, uid next and uid validity are asked too.