aspNetIMAP

ServerResponseEventHandler Delegate

The delegate used for handling the ServerResponse Event.

publicdelegatevoidServerResponseEventHandler(
objectsender,
ServerResponseEventArgse
);

Parameters

sender
The sender object, typically the IMAP4 object.
e
The ServerResponseEventArgs arguments.

Example

          [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

aspNetIMAP Namespace