Occurs when the message was not sent due to an error.
The event handler receives an argument of type SmtpMessageNotSentEventArgs containing data related to this event. The following SmtpMessageNotSentEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| ActualSenderEmail | Gets the e-mail address of the sender of the mail message. |
| IntendedRecipients | Gets the list of recipients the message is addressed to. |
| MailMessage | Gets the mail message which could not be 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. |
| Reason | Gets the exception describing the error which prevented the message from being sent. |
| State | Gets a reference to the object which was supplied by the developer in state parameter of asynchronous methods of the mailer components. |
| Tag | Gets the tag assigned by the developer to SendMailJob of processing the given message. |
This event is a counterpart of MessageSent event.
MessageNotSent event occurs only when there was an attempt to send a message and this attempt failed. Such attempt could be complex, such as sending to a primary and a backup mail servers. If, however, MailBee was unable to send the e-mail to the primary server but managed to send it to the backup one (or send it using alternative method, such as direct send), MessageNotSent will not be raised.
MessageNotSent may occur only for e-mail messages which have already been created. If the error occurred before the message was even built, this event will not occur. The same applies to the events which are raised when a message is about to be sent (or submitted to the pickup folder).
For instance, if SendJobs or SendMailMerge method is running and mail merge of a data row with the mail template failed for some reason, SendingMessage and MessageNotSent events will not occur.
If you have mail merge functionality in your application and need to subscribe to an event which occurs before performing mail merge of a data row with the template, use MergingMessage event.
The example is available at SendMailMerge topic.
Smtp Class | MailBee.SmtpMail Namespace | MessageSent