DeliveryNotificationOptions Class |
Namespace: MailBee.SmtpMail
The DeliveryNotificationOptions type exposes the following members.
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Reset |
Resets all Delivery Status Notification settings back to defaults.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
NotifyCondition |
Gets or sets the events that trigger ESMTP server to send
delivery status notification back to the sender of the message.
| |
ReturnPortion |
Gets or sets how much of the original message is returned with
the delivery status notification when the message delivery fails.
| |
TrackingID |
Gets or sets the unique string (called message transmission envelope)
which will be returned with delivery status notification messages.
|
To access DeliveryNotificationOptions object, use Smtp.DeliveryNotification property.
Note |
---|
If the SMTP server does not support DSN, the values of all the properties of this class are ignored. |
// To use the code below, import these namespaces at the top of your code using System; using MailBee; using MailBee.SmtpMail; // The actual code (put it into a method of your class) Smtp mailer = new Smtp(); // Set Delivery Status Notification settings: // Notify always. mailer.DeliveryNotification.NotifyCondition = DsnNotifyCondition.Always; // Notification message will include the message header of the original messsage. mailer.DeliveryNotification.ReturnPortion = DsnReturnPortion.Header; // Specify some unique string which will be added to notification messages. // It can then be used to match notification message with the original message. mailer.DeliveryNotification.TrackingID = "UNQIUE_STRING_q8sdf74d"; // Set the message fields. mailer.From.AsString = "John Doe <jdoe@domain1.com>"; mailer.To.AsString = "Bill Smith <b.smith@domain2.com>"; mailer.Subject = "Test message"; // Specify SMTP server to use. If your server does not require authentication, // just remove last 2 parameters. mailer.SmtpServers.Add("smtp.domain1.com", "jdoe", "secret"); // Connect to the server and say hello. We need this in order to learn the server // capabilities (such as DSN support). // Alternatively, we could not call Hello() and move DSN status check after Send(), // since Send() method would automatically call Hello() if needed. mailer.Connect(); mailer.Hello(); // Learn if delivery status notifications are supported by the server. if (mailer.GetExtension("DSN") != null) { Console.WriteLine("The message will be submitted with DSN support"); } else { Console.WriteLine("The message will be submitted without DSN support"); } // Send the message. mailer.Send(); Console.WriteLine("The message was successfully submitted to the server."); // Close the connection. mailer.Disconnect();