How to select a subfolder using imap?

0 votes
asked Jul 8 by sked1985 (160 points)

I want to select a sub folder using IMAP. Is there a way of doing this? I want to select "inbox\folder_to_select".

1 Answer

+1 vote
answered Jul 8 by Lukas Pokorny (101,990 points)

IMAP protocol does not have a standard hierarchy delimiter, but most servers use slashes instead of backslashes. So please try this first:

imap.SelectFolder("inbox/folder_to_select");

If it still doesn't work, try listing the server's folder hierarchy to determine names suitable for the SelectFolder method:

var imap = new Imap();
imap.Connect("test.rebex.net", Imap.DefaultImplicitSslPort, SslMode.Implicit);
imap.Login("demo", "password");

ImapFolderCollection folders = imap.GetFolderList("", ImapFolderListMode.All, true);
foreach (ImapFolder folder in folders)
{
    Console.WriteLine(folder.Name);
}
commented Jul 8 by sked1985 (160 points)
Thanks, that seems to work.
...