Folder List

The following example demonstrates using aspNetIMAP to list out the folders of an IMAP mailbox.  In addition to a list of folders, the MailFolderCollection object can also list out the folders as a:

[C#]

   IMAP4 imap = new IMAP4( "127.0.0.1" );
   imap.Logger = new IMAPLog();
   imap.Logger.InMemory = true;
   
   imap.Username = "dave@blah.com";
   imap.Password = "test";
   imap.Login();
   
    //list all of the folders
   MailFolderCollection mfc = imap.FolderList();
   Console.WriteLine( mfc.ToString() );
   
    //write out the log
   Console.WriteLine( imap.Logger.ToString() );
   
   imap.Disconnect();
   
   Console.WriteLine( "Done" );
   Console.ReadLine();

 

[VB.NET]

Dim imap As New IMAP4("127.0.0.1")
imap.Logger = New IMAPLog()
imap.Logger.InMemory = True

imap.Username = "dave@blah.com"
imap.Password = "test"
imap.Login()

'list all of the folders
Dim mfc As MailFolderCollection = imap.FolderList()
Console.WriteLine(mfc.ToString())

'write out the log
Console.WriteLine(imap.Logger.ToString())

imap.Disconnect()

Console.WriteLine("Done")
Console.ReadLine()