SmtpAddJob Method (String, String, EmailAddressCollection)
Puts an e-mail message onto waiting list for subsequent processing in bulk mode.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public void AddJob(
	string tag,
	string senderEmail,
	EmailAddressCollection recipients


Type: SystemString
Any string the developer wants to assign to Tag property of SendMailJob object created by this method. The developer can leave it a null reference (Nothing in Visual Basic).
Type: SystemString
The e-mail address of the sender. If it's a null reference (Nothing in Visual Basic), the e-mail address is taken from From property.
Type: MailBee.MimeEmailAddressCollection
The list of the message recipients. If it's a null reference (Nothing in Visual Basic), the recipients list is combined from To, Cc, and Bcc lists.

This method can be used to send out large volumes of messages (in conjunction with SendJobs method). The given overload composes a single e-mail message from the current values of Message and DeliveryNotification objects and then adds it as a job waiting for processing into JobsPending queue. Then, once SendJobs method has been called, MailBee starts processing all the jobs in this queue and sending out all the accompanied e-mails.

Alternatively, if SubmitJobsToPickupFolder(String, Boolean) has been called instead of SendJobs, the pending e-mails will be saved as .EML files in MailBee.NET Queue or IIS pickup folder.

To destroy finished jobs instead of placing them in JobsSuccessful or JobsFailed collections, subscribe to FinishingJob event and set KeepIt to false. This is useful if you're sending a lot of e-mails and do not want to waste memory with e-mails which have already been processed.

Or, you can set KeepIt to false for failed messages only (so that you could try them again later with RetryFailedJobs method. FinishingJob event provides this information so that you can selectively decide whether you'll need the particular failed or successful message later or not.

Another AddJob(String, String, EmailAddressCollection, DataTable) overload can be used to enqueue a mail merge job of processing a bulk of similar messages based on a common template and a data table.

Note Note
You don't need to re-create or reset Message object (which actually contains the message to be added to the job list) after each call when you're preparing multiple messages. MailBee actually puts a copy of that Message object into the job list. Thus, you're a free to modify its properties again and it won't affect the copy which is already in the job list.
This sample adds two e-mails into the jobs queue and then sends them in a batch.
using System;
using MailBee;
using MailBee.SmtpMail;

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

        // Because SendJobs does not throw exceptions during sending of
        // individual messages, logging is very useful for debugging.
        mailer.Log.Filename = @"C:\Temp\log.txt";
        mailer.Log.Enabled = true;

        mailer.SmtpServers.Add("", "jdoe", "secret");

        // Compose the message #1.
        mailer.From.AsString = "John Doe <>";
        mailer.To.AsString = ", Bob <>";
        mailer.Subject = "This is subject";
        mailer.BodyPlainText = "This is body text";

        // Put the message #1 into the queue. The message will actually be
        // sent from while will appear
        // in "From:" header of the message.
        mailer.AddJob(null, "", null);

        // Compose the message #2.
        mailer.From.AsString = "John Doe <>";
        mailer.To.AsString = "";
        mailer.Subject = "This is another subject";
        mailer.BodyPlainText = "This is another body text";

        // Put the message #2 into the queue.
        mailer.AddJob(null, null, null);

        // Send out the bulk of 2 messages.

        // Print the outcome.
        Console.WriteLine(mailer.JobsSuccessful.Count + " message(s) succeeded");
        Console.WriteLine(mailer.JobsFailed.Count + " message(s) failed");
See Also