Occurs after the message was successfully sent.
The event handler receives an argument of type SmtpMessageSentEventArgs containing data related to this event. The following SmtpMessageSentEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| ActualSenderEmail | Gets the e-mail address of the sender of the mail message. |
| FailedRecipients | Gets the list of recipients the message was not delivered to. |
| IntendedRecipients | Gets the list of recipients the message is addressed to. |
| MailMessage | Gets the mail message which was sent. |
| MergeRowIndex | Gets the index of the data row used for mail merge of this message. |
| MergeTable | Gets the reference to the data table used for mail merge of this message. |
| State | Gets a reference to the object which was supplied by the developer in state parameter of asynchronous methods of the mailer components. |
| SuccessfulRecipients | Gets the list of recipients the message was successfully delivered to. |
| Tag | Gets the tag assigned by the developer to SendMailJob of processing the given message. |
If the message is sent to multiple SMTP servers (common case in direct send mode where the message is submitted to SMTP MX server of each recipient domain separately), this event is raised after the message was submitted to all SMTP servers.
This sample sends a message in direct send mode to 3 recipients on 2 domains. MessageSent event is raised 1 time.
[C#] using System; using MailBee; using MailBee.SmtpMail; class Sample { // MessageSent event handler. private static void OnMessageSent(object sender, SmtpMessageSentEventArgs e) { Console.WriteLine("Sent to: " + e.SuccessfulRecipients.ToString()); } // The actual code. static void Main(string[] args) { Smtp mailer = new Smtp(); // Get DNS servers from config file/OS settings. mailer.DnsServers.Autodetect(); // Subscribe to the MessageSent event. mailer.MessageSent += new SmtpMessageSentEventHandler(OnMessageSent); // Send a message to 3 recipients on 2 domains. mailer.To.AsString = "user1@domain1.com, user2@domain1.com, user2@domain2.com"; mailer.From.Email = "sender@domain.com"; mailer.Subject = "Test message"; mailer.Send(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.SmtpMail Class Sample ' DataSent event handler. Private Shared Sub OnMessageSent(ByVal sender As Object, ByVal e As SmtpMessageSentEventArgs) Console.WriteLine("Sent to: " & e.SuccessfulRecipients.ToString()) End Sub ' The actual code. Shared Sub Main(ByVal args As String()) Dim mailer As New Smtp ' Get DNS servers from config file/OS settings. mailer.DnsServers.Autodetect() ' Subscribe to the MessageSent event. AddHandler mailer.MessageSent, AddressOf OnMessageSent ' Send a message to 3 recipients on 2 domains. mailer.To.AsString = "user1@domain1.com, user2@domain1.com, user2@domain2.com" mailer.From.Email = "sender@domain.com" mailer.Subject = "Test message" mailer.Send() End Sub End Class
Smtp Class | MailBee.SmtpMail Namespace