Requesting read receipt (MDN)

You can also read how to:

Message headers are commonly used to store various e-mail metadata such as spam filtering score, mail agent name or other flags.

Several headers can be used to request a delivery receipt for the message. This will make the recipient’s mail client (such as Outlook) notify the sender if the user have read the message.

Please note that the reply is not mandatory – not all e-mail clients support it and those who do usually ask the user for a permission before sending the receipt. Even though, it is still a useful feature.

As usual different mail clients honor different headers: ‘Disposition-Notification-To’, ‘Return-Receipt-To’ and ‘X-Confirm-Reading-To’.

Mail.dll .NET email client provides you a single method for that: RequestReadReceipt() that copies all addresses from “From” collection or “Reply-To” collection to all those headers.

Read receipt requests may not always be honored. There are several reasons for that:

  • A mail client may not recognize the special Disposition-Notification-To header.
  • A mail client may not implement that functionality.
  • The end user may have that functionality turned off.
  • The end user may optionally not choose to send one for your particular email.

The following code sends email, that requests read receipt:

// C# version:

MailBuilder builder = new MailBuilder();
builder.From.Add(new MailBox("from@example.com", "Alice"));
builder.To.Add(new MailBox("to@example.com", "Bob"));
builder.Subject = "Please let me know if you like it";
builder.Html = "<html>....</html>";

builder.RequestReadReceipt();

IMail email = builder.Create();


using(Smtp smtp = new Smtp())
{
    smtp.Connect("smtp.server.com");  // or ConnectSSL for SSL
    smtp.UseBestLogin("user", "password");
 
    smtp.SendMessage(email);                     
 
    smtp.Close();   
}  

' VB.NET version:

Dim builder As New MailBuilder()
builder.From.Add(New MailBox("from@example.com", "Alice"))
builder.[To].Add(New MailBox("to@example.com", "Bob"))
builder.Subject = "Please let me know if you like it"
builder.Html= "<html>....</html>"

builder.RequestReadReceipt()

Using smtp As New Smtp()
    smtp.Connect("smtp.server.com")	' or ConnectSSL for SSL
    smtp.UseBestLogin("user", "password")

    smtp.SendMessage(email)

    smtp.Close()
End Using

Fluent interface equivalents:

// C# version:

using Fluent = Limilabs.Mail.Fluent;

IMail email = Fluent.Mail.Html("<html>....</html>")
    .Subject("Please let me know if you like it")
    .From("from@example.com")
    .To("to@example.com")
    .RequestReadReceipt()
    .Create();

using(Smtp smtp = new Smtp())
{
    smtp.Connect("smtp.server.com");  // or ConnectSSL for SSL
    smtp.UseBestLogin("user", "password");
 
    smtp.SendMessage(email);                     
 
    smtp.Close();   
}  

and as usual VB.NET code:

' VB.NET version:

Imports Fluent = Limilabs.Mail.Fluent;

Dim email As IMail = Fluent.Mail.Html("<html>....</html>") _
    .Subject("Please let me know if you like it") _
    .From("from@example.com") _
    .[To]("to@example.com") _
    .RequestReadReceipt() _
    .Create()

Using smtp As New Smtp()
    smtp.Connect("smtp.server.com")	' or ConnectSSL for SSL
    smtp.UseBestLogin("user", "password")

    smtp.SendMessage(email)

    smtp.Close()
End Using

Tags:     

Questions?

Consider using our Q&A forum for asking questions.