The following example demonstrates using aspNetIMAP to a header, in
this case the "FROM" header, for an entire email address.
[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(); //explicitly search the 'FROM' header for dave@blah.com //which is different than searching the From Envelope. string queryString = "header FROM \"dave@blah.com\""; string results = mf.SearchClient.Search( queryString ); Console.WriteLine( results ); 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() 'explicitly search the 'FROM' header for dave@blah.com 'which is different than searching the From Envelope. Dim queryString As String = "header FROM ""dave@blah.com""" Dim results As String = mf.SearchClient.Search(queryString) Console.WriteLine(results) imap.Disconnect() 'write out the log Console.WriteLine(imap.Logger.ToString()) Console.WriteLine("Done") Console.ReadLine()