The following example demonstrates how to download the Headers for
all new messages.
[C#]
IMAP4 imap = new IMAP4( "127.0.0.1", "dave@blah.com", "test" ); //set some logging properties imap.Logger = new IMAPLog(); imap.Logger.Overwrite = true; imap.Logger.InMemory = true; imap.Logger.Path = "c:\\imap.log"; imap.Login(); MailFolder mf = imap.SelectInbox(); //grab the headers of the newest messages string[] results = mf.FetchClient.Headers( SearchFlags.New, false ); foreach( string headers in results ) { Console.WriteLine( headers ); } imap.Disconnect(); //write out the log Console.WriteLine( imap.Logger.ToString() ); Console.WriteLine( "Done" ); Console.ReadLine();
[VB.NET]
Dim imap As New IMAP4("127.0.0.1", "dave@blah.com", "test") 'set some logging properties imap.Logger = New IMAPLog() imap.Logger.Overwrite = True imap.Logger.InMemory = True imap.Logger.Path = "c:\imap.log" imap.Login() Dim mf As MailFolder = imap.SelectInbox() 'grab the headers of the newest messages Dim results As String() = mf.FetchClient.Headers(SearchFlags.New, False) Dim headers As String For Each headers In results Console.WriteLine(headers) Next headers imap.Disconnect() 'write out the log Console.WriteLine(imap.Logger.ToString()) Console.WriteLine("Done") Console.ReadLine()