Specifies the maximum number of recipients that can be addressed per message.
The default value is 100. An integer greater than 0.
Most mail servers limit the number of email addresses that a message is addressed to. This is to prevent overloading the mail server and is also a standard. If you receive the error message from your mail server: "Too many recipients", try setting this property to a lower number.
[C#]
public void Send()
{
SmtpServer oSmtpDotNet = new SmtpServer();
// Set the remote server name. If left blank, "localhost" is used.
oSmtpDotNet.ServerAddress = "mail.domain.com";
// Set the limit per message sent to 5.
oSmtpDotNet.DBRecipientLimit = 5;
// Message Addressing
oSmtpDotNet.ToAddress = "to@domain.com";
oSmtpDotNet.FromAddress = "from@domain.com";
// Set the message subject and body
oSmtpDotNet.Body = "This is the message";
oSmtpDotNet.Subject = "Routine email";
ReturnCodes nRC = oSmtpDotNet.Send();
if ( nRC != ReturnCodes.SUCCESS )
{
Console.WriteLine("Error #"+nRC+" occurred.");
Console.WriteLine(oSmtpDotNet.LastError);
Console.Write(oSmtpDotNet.LogFileToString(false));
return;
}
// Success!
Console.WriteLine("Success!");
}
[VB]
Public Function Send() As Integer
Dim oSmtpDotNet As New SmtpServer()
Dim nRC As ReturnCodes
' Set the remote server name. If left blank, "localhost" is used.
oSmtpDotNet.ServerAddress = "mail.domain.com"
' Set the limit per message sent to 5.
oSmtpDotNet.DBRecipientLimit = 5
' Message Addressing
oSmtpDotNet.FromAddress = "from@domain.com"
oSmtpDotNet.ToAddress = "to@domain.com"
' Set the message subject and body
oSmtpDotNet.Subject = "Routine email"
oSmtpDotNet.Body = "This is a briefing of the financials"
' Send the message. Get the return code and store it in the variable
' nRC. Then check nRC for success or failure
nRC = oSmtpDotNet.Send()
If (nRC <> ReturnCodes.SUCCESS) Then
' A problem occurred.
' Write out the last error encountered
Console.WriteLine(oSmtpDotNet.LastError)
' Write out the log file contents
Console.WriteLine(oSmtpDotNet.LogFileToString(False))
Exit Function
End If
' Success!
Console.WriteLine("Message Sent!")
End Function
SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | DBDataTable | DBEmailColumn | DBFriendlyColumn | DBRecipientType