SmtpAddJob Method (String, MailMessage, String, EmailAddressCollection)
Puts the specified 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,
	MailMessage msg,
	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: MailBee.MimeMailMessage
A reference to the mail message to be sent.
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 is similar to AddJob(string, string, EmailAddressCollection) overload but it takes the mail message to be scheduled from msg parameter rather than from Message property.
The version of AddJob(string, string, EmailAddressCollection) sample which explicitly creates a MailMessage instance to add jobs from. This has no practical meaning in this sample but shows how this can be done if for some reason your app already has MailMessage objects to be sent and you don't want to set up a message directly through mailer.Message properties.
using System;
using MailBee;
using MailBee.Mime;
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");

        MailMessage msg = new MailMessage();

        // Compose the message #1.
        msg.From.AsString = "John Doe <>";
        msg.To.AsString = ", Bob <>";
        msg.Subject = "This is subject";
        msg.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, msg, "", null);

        // Note that we do re-recreate a MailMessage object. This overload of AddJob actually places
        // msg itself into the job list, not its copy. For AddJob(string, string, EmailAddressCollection)
        // overload, that would be different (it makes a snapshot of what's currently in mailer.Message
        // and puts a copy of mailer.Message object into the job list, not mailer.Message object itself).
        msg = new MailMessage();

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

        // Put the message #2 into the queue.
        mailer.AddJob(null, msg, 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