SmtpBeginSend Method

Note: This API is now obsolete.

Begins an asynchronous request for sending a mail message to recipients.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use SendAsync instead.")]
public IAsyncResult BeginSend(
	string senderEmail,
	EmailAddressCollection recipients,
	AsyncCallback callback,
	Object state


Type: SystemString
The e-mail address of the sender.
Type: MailBee.MimeEmailAddressCollection
The list of the message recipients.
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
Type: SystemObject
An object that contains state information for this request. You can leave it a null reference (Nothing in Visual Basic).

Return Value

Type: IAsyncResult
An IAsyncResult that references the asynchronous sending the message.
MailBeeInvalidStateExceptionThere is already an operation in progress.
This WinForms sample sends a mail message asynchronously. The callback function is used to receive notification on asynchronous method completion. Events are used to track send mail progress.
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.SmtpMail;
using MailBee.DnsMX;
using MailBee.Mime;

// Put the code below inside your class.

// MessageSubmittedToServer event handler.
private void OnMessageSubmittedToServer(object sender,
    SmtpMessageSubmittedToServerEventArgs e)
    // If no recipients received the message, this event won't be raised.
    // It's safe to assume AcceptedRecipients collection is not empty.
    string domain = e.AcceptedRecipients[0].GetDomain();
    MessageBox.Show("Message was sent to recipients at " + domain + " domain");

// MessageRecipientSubmitted event handler.
private void OnMessageRecipientSubmitted(object sender,
    SmtpMessageRecipientSubmittedEventArgs e)
    // If a particular recipient was refused, let the user know.
    if (!e.Result)
        MessageBox.Show("For e-mail address " + e.RecipientEmail +
            ", server responded: " + e.ServerStatusMessage);

// Send callback function.
private void SendCallback(IAsyncResult result)
    Smtp mailer = (Smtp)result.AsyncState;
    MessageBox.Show("The e-mail was sent to: " +

// The actual code.
private void Form1_Load(object sender, System.EventArgs e)
    Smtp mailer = new Smtp();

    // Enable logging SMTP session into a file.
    mailer.Log.Enabled = true;
    mailer.Log.Filename = @"C:\Temp\log.txt";
    mailer.Log.Format = LogFormatOptions.AddContextInfo;

    // Get the list of DNS servers for MX lookup from OS settings 
    // (app.config/web.config/machine.config files are ignored).
        DnsAutodetectOptions.Registry | DnsAutodetectOptions.Wmi);

    // Subscribe to events.
    mailer.MessageSubmittedToServer +=
        new SmtpMessageSubmittedToServerEventHandler(OnMessageSubmittedToServer);
    mailer.MessageRecipientSubmitted +=
        new SmtpMessageRecipientSubmittedEventHandler(OnMessageRecipientSubmitted);

    mailer.From.Email = "";
    mailer.Subject = "Important details";

    // Demonstrate different methods of adding To, CC, and BCC recipients. 
    mailer.To.AsString = ", \"Bill Smith, Jr.\" <>";
    mailer.Cc.Add("Peter", "");
    mailer.Bcc.AsString = "";

    // Specify HTML body.
    mailer.BodyHtmlText = "<html>Here are the details.</html>";

    // Create plain-text version.

    // Initiate an asynchronous send mail attempt.
    mailer.BeginSend(null, null, new AsyncCallback(SendCallback), mailer);
See Also