SmtpMessageRecipientSubmitted Event |
Occurs each time the next recipient in the mail message recipients list is
accepted or refused by the SMTP server.
Namespace: MailBee.SmtpMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax Remarks If the message contains multiple recipients, this event is raised for each recipient.
The developer can use
Result
property to detremine whether the recipient was accepted or refused.
Note |
---|
If refused recipients are not allowed (AllowRefusedRecipients is false),
the component will cancel the SMTP session after raising MessageRecipientSubmitted event. |
Examples This sample sends a message in direct send mode to 3 recipients on 2 domains.
MessageSenderSubmitted event is raised 3 times (for each recipient).
Note |
---|
In some cases, it may be raised more than 2 times. If certain domain has more than one
SMTP MX server assigned, and sending to high-priority MX server failed after the message
recipient has already been submitted, then backup MX servers are tried (so that the message recipient
is submitted again, and so does MessageRecipientSubmitted event). |
using System;
using MailBee;
using MailBee.SmtpMail;
class Sample
{
private static void OnMessageRecipientSubmitted(object sender,
SmtpMessageRecipientSubmittedEventArgs e)
{
if (e.Result)
{
Console.WriteLine("SMTP server accepted " + e.RecipientEmail + " address");
}
else
{
Console.WriteLine("SMTP server refused " + e.RecipientEmail + " address");
}
}
static void Main(string[] args)
{
Smtp mailer = new Smtp();
mailer.DnsServers.Autodetect();
mailer.MessageRecipientSubmitted +=
new SmtpMessageRecipientSubmittedEventHandler(OnMessageRecipientSubmitted);
mailer.To.AsString = "user1@domain1.com, user2@domain1.com, user2@domain2.com";
mailer.From.Email = "sender@domain.com";
mailer.Subject = "Test message";
mailer.Send();
Console.WriteLine("Message sent to: " + mailer.GetAcceptedRecipients().ToString());
}
}
Imports System
Imports MailBee
Imports MailBee.SmtpMail
Class Sample
Private Shared Sub OnMessageRecipientSubmitted(ByVal sender As Object, ByVal e As SmtpMessageRecipientSubmittedEventArgs)
If e.Result Then
Console.WriteLine("SMTP server accepted " & e.RecipientEmail & " address")
Else
Console.WriteLine("SMTP server refused " & e.RecipientEmail & " address")
End If
End Sub
Shared Sub Main(ByVal args As String())
Dim mailer As New Smtp
mailer.DnsServers.Autodetect()
AddHandler mailer.MessageRecipientSubmitted, AddressOf OnMessageRecipientSubmitted
mailer.To.AsString = "user1@domain1.com, user2@domain1.com, user2@domain2.com"
mailer.From.Email = "sender@domain.com"
mailer.Subject = "Test message"
mailer.Send()
Console.WriteLine("Message sent to: " & mailer.GetAcceptedRecipients().ToString())
End Sub
End Class
See Also