0 votes

My aim is to learn how to change the 'Folder', how to read and delete the emails from the 'Folder' I want?

by (550 points)

1 Answer

0 votes

To change the IMAP folder you simple use the Select method:

using (Imap imap = new Imap())
    imap.UseBestLogin("user", "password");

    imap.Select("Sent items");

    List<long> uids = imap.GetAll();


To use inbox SelectInbox can be used.

You can use GetFolders to list all folders and CommonFolders class to recognize standard folder (even when they are localized):

List<FolderInfo> folders = imap.GetFolders();

CommonFolders common = new CommonFolders(folders);

string inboxName = common.Inbox.Name;
string sentName = common.Sent.Name;
string spamName = common.Spam.Name;

// You can now select those e.g.:
by (276k points)