aspNetIMAP

ServerResponseEventArgs Class

An instance of the ServerResponse Event Args.

For a list of all members of this type, see ServerResponseEventArgs Members.

System.Object
EventArgs
ServerResponseEventArgs

publicclassServerResponseEventArgs : EventArgs

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Example

The following example demonstrates capturing the session between the IMAP server and the client.

[C#]
static void Main(string[] args)
{
 
    IMAP4 imap = new IMAP4( "127.0.0.1" );
 
    //wire up the server event, so we can watch the commands to the imap server, in real time.
    imap.ServerResponse += new ServerResponseEventHandler( OnServerResponse );
 
    imap.Username = "dave@blah.com";
    imap.Password = "test";
    imap.Login();
 
    //grab the inbox
    MailFolder mf = imap.SelectInbox();
    
    //grab the headers of the 1st message
    string headers = mf.FetchClient.Headers( 1, IndexType.Ordinal );
 
    imap.Disconnect();
 
    //write the the headers 
    Console.WriteLine( headers );
 
 
    Console.WriteLine( "Done" );
    Console.ReadLine();
 
}
 
private static void OnServerResponse( object sender, ServerResponseEventArgs e )
{
    //write out various information
 
    //imap command
    Console.WriteLine( e.Command );
 
    //number of bytes
    Console.WriteLine( e.DataCount );
 
    //message
    Console.WriteLine( Encoding.ASCII.GetString( e.Data, 0, e.DataCount ) );
    
}
[VB.NET]
'Entry point which delegates to C-style main Private Function
Public Overloads Shared Sub Main()
   Main(System.Environment.GetCommandLineArgs())
End Sub
 
Overloads Shared Sub Main(args() As String)
   
   Dim imap As New IMAP4("127.0.0.1")
   
   'wire up the server event, so we can watch the commands to the imap server, in real time.
   AddHandler imap.ServerResponse, AddressOf OnServerResponse
   
   imap.Username = "dave@blah.com"
   imap.Password = "test"
   imap.Login()
   
   'grab the inbox
   Dim mf As MailFolder = imap.SelectInbox()
   
   'grab the headers of the 1st message
   Dim headers As String = mf.FetchClient.Headers(1, IndexType.Ordinal)
   
   imap.Disconnect()
   
   'write the the headers 
   Console.WriteLine(headers)
   
   
   Console.WriteLine("Done")
   Console.ReadLine()
End Sub 'Main
 
 
Private Shared Sub OnServerResponse(sender As Object, e As ServerResponseEventArgs)
   'write out various information
   'imap command
   Console.WriteLine(e.Command)
   
   'number of bytes
   Console.WriteLine(e.DataCount)
   
   'message
   Console.WriteLine(Encoding.ASCII.GetString(e.Data, 0, e.DataCount))
End Sub 'OnServerResponse
    

Requirements

Namespace: aspNetIMAP

Assembly: aspNetIMAP (in aspNetIMAP.dll)

See Also

ServerResponseEventArgs Members | aspNetIMAP Namespace