Delivery Status Notification Type Enumeration
Delivery status notification type.
Definition
Namespace: MailKit
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
public enum DeliveryStatusNotificationTypeRemarks
The delivery status notification type specifies whether or not
the full message should be included in any failed DSN issued for
a message transmission as opposed to just the headers.
Example
C#
public static void SendWithDeliveryStatusNotifications (MimeMessage message)
{
var request = new SmtpSendRequest (message) {
// Since you will want to be able to map the envelope identifier back to the
// message, the obvious identifier to use is probably the Message-Id value.
EnvelopeId = message.MessageId,
// Request that the server include only the headers of the original message
// in any delivery status notifications that it sends back.
DeliveryStatusNotificationType = DeliveryStatusNotificationType.HeadersOnly,
// In this example, we only want to be notified of failures to deliver to a mailbox.
// If you also want to be notified of delays or successful deliveries, simply bitwise-or
// whatever combination of flags you want to be notified about.
DeliveryStatusNotifications = DeliveryStatusNotification.Failure
};
using (var client = new SmtpClient ()) {
client.Connect ("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
client.Authenticate ("username", "password");
var result = (SmtpSendResult) client.Send (request);
Console.WriteLine ($"The server responded with: {result.StatusCode} {result.ResponseText}");
client.Disconnect (true);
}
}
public class PerRecipientSmtpSendRequest : SmtpSendRequest
{
public PerRecipientSmtpSendRequest (MimeMessage message) : base (message)
{
EnvelopeId = message.MessageId;
}
/// <summary>
/// Get the types of delivery status notification desired for the specified recipient mailbox.
/// </summary>
/// <remarks>
/// Gets the types of delivery status notification desired for the specified recipient mailbox.
/// </remarks>
/// <returns>The desired delivery status notification type.</returns>
/// <param name="recipient">The recipient mailbox.</param>
public override DeliveryStatusNotification? GetDeliveryStatusNotifications (MailboxAddress recipient)
{
// Only request delivery status notifications for recipients outside of our domain.
if (recipient.Domain.Equals ("example.com", StringComparison.OrdinalIgnoreCase))
return DeliveryStatusNotification.Never;
return DeliveryStatusNotification.Failure | DeliveryStatusNotification.Delay;
}
}
Members
| Unspecified | 0 | The return type is unspecified, allowing the server to choose. |
| Full | 1 | The full message should be included in any failed delivery status notification issued by the server. |
| HeadersOnly | 2 | Only the headers should be included in any failed delivery status notification issued by the server. |