Summary description for SearchClient.
For a list of all members of this type, see SearchClient Members.
System.Object
SearchClient
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
A word about searching for addresses.
When email addresses are searched, they are not searched in their entirety. Instead their parsed Envelope elements are searched. Some more information about IMAP Envelopes can be found below, and also at the Envelope class.
The IMAP Envelope
Envelope structures simplify querying IMAP servers for information about specific messages. An envelope structure is a subset of the message header that provides a convenient subset of the message for folder summaries.
Background Information From the RFCs
IMAP envelope fields are presented in the following format:
Date
Subject
From
Sender
Reply-To
To
Cc
Bcc
In-Reply-To
Message-Id
If the contents of the ReplyTo field are not found, they are populated with the value in the From field. With the exception of the Address fields, the contents are presented as a quoted strings.
Address Fields
The address fields (From, Sender, Reply-To, To, Cc, Bcc ) are presented as a parenthetical list that contains the parsed elements of the address. This is important to know, because it's these elements that are searched against, not the email address in its entirety.
Each address is divided into the following elements, in this order:
Personal Name
SMTP Source Route
Mailbox Name
Domain Name
For any of these values, that don't exist, a NIL string is inserted. This is important to note, because only these elements can be searched, not the address in its entirety, as a string.
Some Address Examples
So what does a parsed address look like? Lets take for example "Terry Gray <gray@cac.washington.edu>", this address is parsed into the following string
(("Terry Gray" NIL "gray" "cac.washington.edu"))
Thus, if you wanted to search for this address, using the SearchClient, some code might look like:
//get the inbox
MailFolder mf = imap.SelectInbox();
//search for an address with "cac.washington.edu" in it.
string results = mf.SearchClient.SearchFrom( "cac.washington.edu" );
'results' would contain an IMAP list of messages that have "cac.washington.edu" in the domain.
[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();
//search the subject header for the word "number"
string results = mf.SearchClient.SearchSubject( "number" );
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()
'search the subject header for the word "number"
Dim results As String = mf.SearchClient.SearchSubject("number")
Console.WriteLine(results)
imap.Disconnect()
'write out the log
Console.WriteLine(imap.Logger.ToString())
Console.WriteLine("Done")
Console.ReadLine()
Namespace: aspNetIMAP
Assembly: aspNetIMAP (in aspNetIMAP.dll)