SmtpBeginSendJobs Method

Note: This API is now obsolete.

Begins an asynchronous request to process the pending jobs and send out the resulting e-mails.

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 SendJobsAsync instead.")]
public IAsyncResult BeginSendJobs(
	AsyncCallback callback,
	Object state


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 asynchronous sending e-mails accordingly the assigned pending jobs.
This console sample performs mail merge asynchronously. The sample gets notified of mail merge completion by using a callback function.
using System;
using System.Data;
using System.Data.OleDb;
using System.Threading;
using MailBee;
using MailBee.Mime;
using MailBee.SmtpMail;

class Sample
    private static bool finished = false;

    // SendJobs callback function.
    private static void SendJobsCallback(IAsyncResult result)
        Smtp mailer = (Smtp)result.AsyncState;


        // Report results (row indices in the data table) to the console.
        if (mailer.JobsFailed.Count == 0)
            Console.WriteLine("Newsletter has been sent out without any errors.");
            if (mailer.JobsSuccessful.Count == 0)
                Console.WriteLine("All newsletter e-mails failed to be sent.");
            else if (mailer.JobsFailed.Count > 0)
                Console.WriteLine("Not all newsletter e-mails have been sent.");

                // Obtain a reference to the DataTable used for mail merge.
                DataTable table = mailer.JobsFailed[0].MergeTable;

                Console.WriteLine("Successful rows: ");
                Console.WriteLine(mailer.JobsSuccessful.GetIndicesAsString(table, null));

                Console.WriteLine("Failed rows: ");
                Console.WriteLine(mailer.JobsFailed.GetIndicesAsString(table, null));
                Console.WriteLine("There was nothing to send.");


        finished = true;

    static void Main(string[] args)
        Smtp mailer = new Smtp();

        // Logging into a file is useful for troubleshooting.
        mailer.Log.Filename = @"C:\Temp\log.txt";
        mailer.Log.Enabled = true;
        mailer.Log.Format = LogFormatOptions.AddContextInfo;

        // Uncomment the line below to use unlimited number of worker threads (up to 60)
        // and increase performance. Note that not all SMTP servers support this.

        // mailer.MaxThreadCount = -1;

        // Setup SMTP server parameters.
        mailer.SmtpServers.Add("", "jdoe", "secret");

        // Setup e-mail message header template for mail merge.
        mailer.Message.From.AsString = "John Doe <>";
        mailer.Message.To.AsString = "##Name## <##Email##>";
        mailer.Message.Subject = "Our newsletter";

        // Setup HTML body template.
        mailer.Message.BodyHtmlText = "<html>##Body##</html>";

        // Specify database connection string (it may be different in your case).
        string connParams = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Temp\newsletter.mdb;";

        // Connect to the database and populate mail merge job to-do list with
        // the data from "mailing_list" table.
        using (OleDbConnection conn = new OleDbConnection(connParams))
            // Open the connection and get the data.
            OleDbCommand command = new OleDbCommand("SELECT * FROM mailing_list", conn);
            DataTable table = new DataTable();
            OleDbDataAdapter adapter = new OleDbDataAdapter();
            adapter.SelectCommand = command;

            // Create a job which is the following task for MailBee: perform mail merge
            // of a newsletter template with data rows of the specified data table and
            // send out each resulting e-mail to its intended recipients.
            mailer.AddJob(null, null, null, table);

        // Start processing jobs. The actual mail merge takes place here.
        mailer.BeginSendJobs(new AsyncCallback(SendJobsCallback), mailer);

        // Can do anything else while the mail merge takes place in the background.
        while (!finished)

        Console.WriteLine("Processing jobs done.");
See Also