PowerTCP Mail for .NET
SendEventHandler Delegate
See Also  Example Send comments on this topic.
Dart.PowerTCP.Mail Namespace : SendEventHandler Delegate




sender
e
Represents the method (event handler) that will be raised when the Smtp.BeginSend operation completes.

Syntax

Visual Basic (Declaration) 
Public Delegate Sub SendEventHandler( _
   ByVal sender As Object, _
   ByVal e As SmtpEventArgs _
) 
Visual Basic (Usage)Copy Code
Dim instance As New SendEventHandler(AddressOf HandlerMethod)
C# 
public delegate void SendEventHandler( 
   object sender,
   SmtpEventArgs e
)
Managed Extensions for C++ 
public: __gc __delegate void SendEventHandler( 
   Object* sender,
   SmtpEventArgs* e
)
C++/CLI 
public delegate void SendEventHandler( 
   Object^ sender,
   SmtpEventArgs^ e
)

Parameters

sender
e

Example

The following example demonstrates how to assign an event handler to an event.
Visual BasicCopy Code
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail"
' at the top of your class.

' *** EndSend Event ***

' You can either use the AddHandler statement to associate an event with an event handler in your init code
AddHandler Smtp1.EndSend, New Dart.PowerTCP.SendEventHandler(AddressOf Smtp1_EndPut)

' Or you can use the Handles keyword to associate an event handler with an event
Private Sub Smtp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.Mail.SmtpEventArgs) Handles Smtp1.EndSend
End Sub
C#Copy Code
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;"
// at the top of your class.

// EndSend event
this.smtp1.EndSend += new Dart.PowerTCP.Mail.SendEventHandler(this.smtp1_EndSend);

Remarks

As Microsoft describes in their MSDN documentation, the event model in the .NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed:

  • A class that holds the event data. This class must derive from the base class EventArgs.
  • A delegate that points to a method that provides the response to the event.
When using the Smtp.BeginSend method, the class that holds the event data is the SmtpEventArgs class. A method must be created with the same signature as the SmtpEventArgs delegate. If you are working within the Visual Studio .NET environment, this can be automatically done for you. See the "Using Events In PowerTCP" topic for more information. If you are not working within the Visual Studio .NET environment, you must do this yourself. In this example that would mean a method would have to be defined to accept two arguments (an object and an SmtpEventArgs) and return void. Once this has been done, the delegate must be "connected" to the handling event. This is done by adding an instance of the delegate to the event (see examples below).

For more information about event handler delegates, see the "Using Events In PowerTCP" topic.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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