PowerTCP Mail for .NET
LineReceived Event
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace > Imap Class : LineReceived Event




Raised each time a line response is received from the server.

Syntax

Visual Basic (Declaration) 
<CategoryAttribute("Progress")>
Public Event LineReceived As ImapResponseEventHandler
Visual Basic (Usage)Copy Code
Dim instance As Imap
Dim handler As ImapResponseEventHandler
 
AddHandler instance.LineReceived, handler
C# 
[CategoryAttribute("Progress")]
public event ImapResponseEventHandler LineReceived
Managed Extensions for C++ 
[CategoryAttribute("Progress")]
public: __event ImapResponseEventHandler* LineReceived
C++/CLI 
[CategoryAttribute("Progress")]
public:
event ImapResponseEventHandler^ LineReceived

Event Data

The event handler receives an argument of type ImapResponseEventArgs containing data related to this event. The following ImapResponseEventArgs properties provide information specific to this event.

PropertyDescription
Exception (Inherited from Dart.PowerTCP.Mail.EndEventArgs) Gets any exception which occurred during the asynchronous operation.
Response Gets an ImapResponse object representing a single line response from the IMAP server.
Responses Gets an array of ImapResponse objects representing all responses from the IMAP server applicable to this event.
State (Inherited from Dart.PowerTCP.Mail.EndEventArgs) Gets the object that was included as part of the associated method call.

Example

The following example demonstrates using the LineReceived event to detect Status responses.
Visual BasicCopy Code
Private Sub DoSomething()
   ' Log in. The Imap.LineReceived event will be raised when data is received
   Imap1.Login(Server, User, Pass)

   ' Send a NOOP
   Imap1.Noop()

   ' Log out
   Imap1.Logout()
End Sub

Private Sub Imap1_LineReceived(ByVal sender As Object, ByVal e As Dart.PowerTCP.Mail.ImapResponseEventArgs) Handles Imap1.LineReceived
   Dim Response As ImapResponse
   ' Iterate through all responses.
   For Each Response In e.Responses
      ' Check if it is a status response. 
      If Response.ResponseType = ImapResponseType.Status Then 
         Debug.WriteLine("The server has returned a status response")
         Debug.WriteLine("Status: " + Response.Status)
         Debug.WriteLine("Explanation: " + Response.Explanation)
      End If
   Next
End Sub
C#Copy Code
private void DoSomething()
{
   // Log in. The Imap.LineReceived event will be raised when data is received
   imap1.Login(Server, User, Pass);

   // Send a NOOP
   imap1.Noop();

   // Log out
   imap1.Logout();
}

private void imap1_LineReceived(object sender, Dart.PowerTCP.Mail.ImapResponseEventArgs e)
{
   // Iterate through all responses.
   foreach(ImapResponse response in e.Responses)
   {
      // Check if it is a status response.
      if(response.ResponseType == ImapResponseType.Status)
      {
         Debug.WriteLine("The server has returned a status response");
         Debug.WriteLine("Status: " + response.Status);
         Debug.WriteLine("Explanation: " + response.Explanation);
      }
   }
}

Remarks

This event is raised each time a line response is received from the server. An ImapResponse object which encapsulates the update received from the server is passed into the event handler.

For more information on using PowerTCP events, see the topic Using Events In PowerTCP.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 3.2
© 2010 Dart Communications. All Rights Reserved.