Hello Everyone and thanks for your help in advance. I am working on a web form that sends an email. I need to be able to obtain some type of delivery receipt or status. I have tried the following code:
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
But when the email is sent (I am sending it to my Exchange server for testing), no delivery receipt is returned. Everything else seems to work fine. Any help would be appreciated.
Usually there will be prompt from the user end to send the Delivery Notification. Is it prompting that for you?
I don't think the delivery receipt requires a prompt from the user. However, the read receipt does and it does prompt the user to confirm it was read.
It is hard to say what is the main issue according to your description. Please check the demo below about how to send messages about both successfully sent and failed emails to the sender's email address.
MailMessage msg = new MailMessage(); msg.From = "email@example.com"; msg.To = "firstname.lastname@example.org"; msg.Subject = "the subject of the message"; // Set delivery notifications for success and failed messages msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.OnFailure; // Add the MIME headers msg.Headers.Add_(new MimeHeader("Read-Receipt-To", "email@example.com")); msg.Headers.Add_(new MimeHeader("Disposition-Notification-To", "firstname.lastname@example.org")); SmtpClient client = new SmtpClient("host", "username", "password"); client.Send(msg);
In addition, please add the reference as follows:
Thanks for the response. Here is what the email headers look like:
Microsoft Mail Internet Headers Version 2.0 Received: from MY-PC ([server IP]) by mail.mydomain.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 27 Aug 2012 21:02:41 -0400 Disposition-Notification-To: email@example.com Return-Receipt-To: firstname.lastname@example.org MIME-Version: 1.0 From: "Sender Display Name" <email@example.com> To: "Receiver Display Name" <firstname.lastname@example.org> X-Priority: 1 Priority: urgent Importance: high Date: 27 Aug 2012 21:10:51 -0400 Subject: Subject Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: base64 Return-Path: email@example.com Message-ID: <SERVER5K6qHN1gHrQ5Ne0000788a@mail.mydomain.com> X-OriginalArrivalTime: 28 Aug 2012 01:02:41.0671 (UTC) FILETIME=[D340F170:01CD84B8]
So it appears to be correctly sent. I'm wondering if it might be my mail server, but it works fine with Outlook.