If need to download mails from different IMAP folder than Inbox, you need to use overloaded Imap.Select method, which takes string parameter (folder name) or FolderInfo parameter (returned from a call to Imap.GetFolders method).
(You can list all IMAP folders using Imap.GetFolders method, to get all IMAP folders.)
After that you can use Imap.GetAll or Imap.Search and Imap.GetMessageByUID methods to search and download mail messages:
using (Imap imap = new Imap())
{
imap.Connect("imap.example.com"); // or ConnectSSL for SSL
imap.UseBestLogin("user", "password");
imap.Select("Sent items");
List<long> uids = imap.GetAll();
foreach (long uid in uids)
{
IMail email = new MailBuilder()
.CreateFromEml(imap.GetMessageByUID(uid));
string subject = email.Subject;
}
imap.Close();
}
There is no established standard on naming common IMAP folders like ‘Sent mail’, ‘Spam’ etc. Nevertheless in most cases you can use CommonFolders class to recognize common folders, such as Sent Mail.
CommonFolders common = new CommonFolders(imap.GetFolders());
imap.Select(common.Sent);