aspNetEmail

EmailMessage.BeginSend Method 

Begins an asynchronous request to send an email.

public IAsyncResult BeginSend(
   AsyncCallback callBack,
   object state
);

Parameters

callBack
The AsyncCallback
state
The State object

Return Value

An IAsyncResult instance that references the asynchronous request.

Example

[C#]
		 static void SendEmail()
		 {
		 	EmailMessage msg  = new EmailMessage();
		 	msg.Server = "mail.mycompany.com";
		 	msg.FromAddress = "me@mycompany.com";
		 	msg.To="you@mycompany.com";
		 	msg.Subject = "this email was sent async";
		 
		 	msg.Body = "the email body goes here";
		 
		 
		 	msg.BeginSend(new AsyncCallback( MyCallback ), msg );
		 	Console.WriteLine( "sent async....");
		 
		 }
		 static void MyCallback( IAsyncResult result )
		 {
		 	EmailMessage msg = (EmailMessage)result.AsyncState;
		 	bool success = msg.EndSend( result );
		 	Console.WriteLine( "success: " + success );
		 }
		 
[Visual Basic]
		  Sub SendEmail()
		      Dim msg As New EmailMessage()
		      msg.Server = "mail.mycompany.com"
		      msg.FromAddress = "me@mycompany.com"
		      msg.To = "you@mycompany.com"
		      msg.Subject = "this email was sent async"
		 
		      msg.Body = "the email body goes here"
		 
		      msg.BeginSend(AddressOf MyCallback, msg)
		      Console.WriteLine("sent async....")
		  End Sub 'SendEmail
		 
		  Sub MyCallback(ByVal result As IAsyncResult)
		      Dim msg As EmailMessage = CType(result.AsyncState, EmailMessage)
		      Dim success As Boolean = msg.EndSend(result)
		      Console.WriteLine("success: " + success)
		  End Sub 'MyCallback
		 

See Also

EmailMessage Class | aspNetEmail Namespace