Sending Emails with Delivery Receipt Notification

Of late, I was getting few queries on how to get email delivery notification and email read notifications when sending emails programmatically using the .NET Framework classes (System.Net.Mail). Getting email read notification option is done by adding a custom header called Disposition-Notification-To to the mail message:

System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();

mm.From = new System.Net.Mail.MailAddress(“sender email address”);

mm.To.Add(“recv email address”);

mm.Headers.Add (“Disposition-Notification-To”, “email address”);

 

I thought configuring the email message to receive read-receipt is easier than delivery-receipt. But, after looking a bit deeper at the MailMessage class properties, adding delivery-receipt notification option is just built in!

mm.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnSuccess;

The above setting marks it to send a receipt on successful email delivery. You can also receive notifications when the email delivery is failed or delayed; you can combine these options too. See the documentation for System.Net.Mail.DeliveryNotificationOptions for more details.

May internet resources say that adding “Return-Receipt-To” custom header (like Disposition-Notification-To above) to the mail message will enable delivery-receipt notification but I believe it is not a standard though it works in many cases.