Saturday, August 20, 2011

How can I get a delivery failed notification to sender email when sent email fails to deliver?


MailMessage class have a property named “DeliveryNotificationOptions” and an enumeration of type “DeleiveryNotificationOptions”. DeleiveryNotificationOptions enumeration have values: OnSuccess, OnFailure, Delay, None and Never. You can instruct the SMTP server to send a message to the address of email sender specified in MailMessage.From if message delivery fails, delayed or successfully delivered etc. Following code snippet shows how to set for OnFailure:
MailMessage mail = new MailMessage();
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

No comments:

Post a Comment