SmtpSend Method (String, String)
Sends the mail message to the specified recipients e-mail addresses.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.0.0 build 569 for .NET 4.5
public bool Send(
	string senderEmail,
	string recipientEmails


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: SystemString
The comma-separted list of the recipients e-mail addresses. If it's a null reference (Nothing in Visual Basic), the recipients list is combined from To, Cc, and Bcc lists.

Return Value

Type: Boolean
true if the method succeeds; otherwise, false.
MailBeeExceptionAn error occurred and ThrowExceptions is true.
PlatformNotSupportedExceptionIn .NET Core, multi-threaded sending is supported with async methods only. Use SendAsync(String, String) instead.

QuickSend(MailMessage) method can be used to send a mail message with a single line of code.

SendMailMerge(String, EmailAddressCollection, DataTable) or SendJobs methods perform sending of large volumes of e-mails including mail merge over database.

To specify international e-mail addresses (IDN domains), call EscapeIdnDomain(String) for senderEmail string and for each individual value in recipientEmails to convert e-mail addresses from human-readable into SMTP-safe format.

Message property represents the mail message to be sent.

Log object can be used to enable logging SMTP session into a file or memory buffer.

Delivery status notifications can be enabled and configured by setting DeliveryNotification properties.

UploadMessage(MailMessage, String, SystemMessageFlags) method can be used to upload the sent message into IMAP4 folder such as "Sent items".

The operation progress can be monitored through subscribing to Smtp class events or by deriving a new class from Smtp and overriding OnEventName methods.

If Connect method was previously called and the connection with the SMTP relay server was established, Send method will send the message to this server.

If Connect method was not called, Send method will automatically connect to the server specified in SmtpServers collection, send the message, and then disconnect.

If SmtpServers collection contains more than one server, Connect method will try to send the message to the top priority server (see Priority). If it fails, other servers will be tried accordingly their priority values.

If SmtpServers collection is empty or the priority of the most preferred SMTP relay server in SmtpServers collection is less than than the priority of the most preferred DNS server in DnsServers collection, the message will be sent in direct send mode. In this mode, MailBee performs DNS MX lookup for all recipients domains to discover which hosts accept mail for these domains (such hosts are called SMTP MX servers), and then sends the message directly to these servers. In other words, MailBee itself will act as a relay SMTP server. However, it's recommended sending host have assigned DNS MX or A record. Systems which actively send mail but don't have any DNS records assigned are typically used by spammers, thus many SMTP MX servers will not accept mail from such host and may even blacklist its IP address.

If both SmtpServers and DnsServers collections are non-empty, the collection having higher priority server will be tried first (if top priority servers of both collections have the same priority, SmtpServers is preferred). If sending to some or all recipients fails due to failure of some servers, another collection will be used to send the message to the failed recipients. Thus, sending to both SMTP relay servers and servers discovered via DNS MX lookup can be performed in a single Send method call, providing high level of reliability of send mail operation.

Note Note
SMTP and DNS server priority values are zero-based. 0 is the highest priority while 999 is the lowest priority.

In direct send mode, it's possible to send the message to all SMTP MX servers simultaneously. This may greatly improve performance when sending to multiple recipients. The developer can enable multi-threading by setting MaxThreadCount property value to -1 (unlimited number of thread) or to the maximum number of threads the application is allowed to use.

This sample sends a message from address different from From: address specified in the message. This is useful when bounced messages should be processed and the developer wants to redirect bounced messages to another address. In this sample, From: is while real sender's address (which will appear in Return-Path header value and where bounces will arrive to) is
// To use the code below, import these namespaces at the top of your code.
using System;
using MailBee;
using MailBee.SmtpMail;
using MailBee.Mime;

// The actual code (put it into a method of your class)

Smtp mailer = new Smtp();

// Specify SMTP server to use, and enable SMTP authentication. Remove 
// last 2 parameters if authentication is not required by your server. 
// If your server requires authentication and expects e-mail address to 
// be specified as login name, use "" instead of "bounce".
mailer.SmtpServers.Add("", "bounce", "password");

// Uncomment next line if ESMTP CHUNKING causes problems with your server (usually, with MS Exchange).
// mailer.SmtpServers[0].SmtpOptions = ExtendedSmtpOptions.NoChunking;

// Specify From: field.
mailer.From.AsString = "John Doe <>";

// Set recipients
mailer.To.AsString = "Bill Smith <>;,";

mailer.Subject = "Report";
mailer.BodyPlainText = "This is the report.";

// Send from rather than
// will appear in Return-Path header.
// We set recipientEmails=null to send to addresses specified in the message.
mailer.Send("", (string)null);

Console.WriteLine("Sent to: " + mailer.GetAcceptedRecipients().ToString());
See Also