Raised when the Smtp.BeginSend request completes.
Syntax
| Visual Basic (Usage) | Copy Code |
|---|
Dim instance As Smtp
Dim handler As SendEventHandler
AddHandler instance.EndSend, handler |
Event Data
The event handler receives an argument of type SmtpEventArgs containing data related to this event. The following SmtpEventArgs properties provide information specific to this event.
| Property | Description |
|---|
| Exception | Gets any exception which occurred during the asynchronous operation. |
| Response | Gets the SmtpResult object, encapsulating data about the message sent. |
| State | Gets the object that was included as part of the associated method call. |
Example
The following example demonstrates using the Smtp.BeginSend method and the Smtp.EndSend event.
| Visual Basic | Copy Code |
|---|
' Be sure to import the namespace by putting "Imports Dart.PowerTCP.Mail"
' at the top of your class.
Private Sub BeginSendTest()
' Begin to asynchronously send a message
Smtp1.Server = "mail.test.com"
Smtp1.BeginSend("you@test.com", "me@test.com", "test", "test message", Nothing)
End Sub
Private Sub Smtp1_EndSend(ByVal sender As Object, ByVal e As Dart.PowerTCP.Mail.SmtpEventArgs) Handles Smtp1.EndSend
' Send operation complete. Check to see if an exception was thrown during the operation.
If e.Exception Is Nothing Then
Debug.WriteLine("Send operation complete")
Dim m As MailAddress
For Each m In e.Response.Recipients
Debug.WriteLine("Mail sent to " + m.Address)
Next
End If
End Sub |
| C# | Copy Code |
|---|
// Be sure to import the namespace by putting "using Dart.PowerTCP.Mail;"
// at the top of your class.
private void BeginSendTest()
{
// Begin to asynchronously send a message
smtp1.Server = "mail.test.com";
smtp1.BeginSend("you@test.com", "me@test.com", "test", "test message", null);
}
private void smtp1_EndSend(object sender, Dart.PowerTCP.Mail.SmtpEventArgs e)
{
// Send operation complete. Check to see if an exception was thrown during the operation.
if(e.Exception == null)
{
Debug.WriteLine("Send operation complete");
foreach(MailAddress m in e.Response.Recipients)
Debug.WriteLine("Mail sent to " + m.Address);
}
} |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0
See Also