The following example demonstrates using aspNetIMAP to search the FROM address for the domain "Microsoft.com"
By default, the IMAP protocol does not allow searching for the entire address, only parts of it. To search for an entire address, an IMAP formatted querystring must be created. Check out this Search Example II, to see how this is accomplished.
[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(); string results = mf.SearchClient.SearchFrom( "microsoft.com" ); 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() Dim results As String = mf.SearchClient.SearchFrom("microsoft.com") Console.WriteLine(results) imap.Disconnect() 'write out the log Console.WriteLine(imap.Logger.ToString()) Console.WriteLine("Done") Console.ReadLine()