Provides properties and methods which control how and when ESMTP Delivery Status Notifications (DSN) are sent.
For a list of all members of this type, see DeliveryNotificationOptions Members.
System.Object
MailBee.SmtpMail.DeliveryNotificationOptions
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
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.
This sample checks whether the server supports DSN's, submits a message to the server, and tells the server to send DSN on any outcome (sent successfully, failed, or delayed). The DSN message will include the header of the original message.
[C#] // 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();
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code Imports MailBee Imports MailBee.SmtpMail ' The actual code (put it into a method of your class) Dim mailer As 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 Not mailer.GetExtension("DSN") Is Nothing Then Console.WriteLine("The message will be submitted with DSN support") Else Console.WriteLine("The message will be submitted without DSN support") End If ' Send the message. mailer.Send() Console.WriteLine("The message was successfully submitted to the server.") ' Close the connection. mailer.Disconnect()
Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll)
DeliveryNotificationOptions Members | MailBee.SmtpMail Namespace