SmtpMail.DeliveryNotification Property


Gets or sets the delivery notifications for this e-mail message.

[Visual Basic]
Public Property DeliveryNotification As DeliveryNotificationOptions
[C#]
public DeliveryNotificationOptions DeliveryNotification {get; set;}
[C++]
public: __property DeliveryNotificationOptions^ get_DeliveryNotification();
public: __property void set_DeliveryNotification(DeliveryNotificationOptions^);
[JScript]
public function get DeliveryNotification() : DeliveryNotificationOptions;
public function set DeliveryNotification(DeliveryNotificationOptions);

Property Value

Any combination of DeliveryNotificationOptions values.

Remarks

If you don't set this property, SMTP server only sends the failure report back to the sender. Because not every SMTP server support above options, if you don't have special requirement, please set it to DeliveryNotificationOptions.None (default). You always get Failure Report from SMTP server even you set this property to DeliveryNotificationOptions.None.

Import Notice: Not every SMTP server support Delivery Receipt. Only the SMTP server that supports DSN extension command accepts Delivery Receipient request, otherwise you will get error when you are sending email.

The following example codes demonstrate how to request read receipt and delivery receipt:

[C#]
// The following example codes demonstrate requesting read receipt and delivery receipt
// To get full sample projects, please download and install EASendMail on your machine.
// To run it correctly, please change SMTP server, user, password, sender, recipient value to yours

using System;  
using System.Text; 
using EASendMail; 

void SendMail()
{
    try
    {
        SmtpMail oMail = new SmtpMail("TryIt");
        // Set sender email address, please change it to yours
        oMail.From = "test@emailarchitect.net";
        // Set recipient email address, please change it to yours
        oMail.To = "support@emailarchitect.net";

        // Set email subject
        oMail.Subject = "test email from c# project";
        // Set email body
        oMail.TextBody = "this is a test email sent from c# project, do not reply";

        // Request read receipt
        oMail.ReadReceipt = true;

        // Request both failure and success report
        oMail.DeliveryNotification = DeliveryNotificationOptions.OnFailure |
            DeliveryNotificationOptions.OnSuccess;

        // Your SMTP server address
        SmtpServer oServer = new SmtpServer("smtp.emailarchitect.net");

        // User and password for ESMTP authentication
        oServer.User = "test@emailarchitect.net";
        oServer.Password = "testpassword";

        // Most mordern SMTP servers require SSL/TLS connection now.
        // ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically.
        oServer.ConnectType = SmtpConnectType.ConnectTryTLS;

        SmtpClient oSmtp = new SmtpClient();
        oSmtp.SendMail(oServer, oMail);

        Console.WriteLine("email was sent successfully!");
    }
    catch (Exception ep)
    {
        Console.WriteLine("failed to send email {0}", ep.Message);
    }
}


[VB] ' The following example codes demonstrate requesting read receipt and delivery receipt ' To get full sample projects, please download and install EASendMail on your machine. ' To run it correctly, please change SMTP server, user, password, sender, recipient value to yours Imports EASendMail Sub SendMail() Try Dim oMail As New SmtpMail("TryIt") ' Set sender email address, please change it to yours oMail.From = "test@emailarchitect.net" ' Set recipient email address, please change it to yours oMail.To = "support@emailarchitect.net" ' Set email subject oMail.Subject = "test email from VB.NET project" ' Set email body oMail.TextBody = "this is a test email sent from VB.NET project, do not reply" ' Your SMTP server address Dim oServer As New SmtpServer("smtp.emailarchitect.net") ' User and password for ESMTP authentication oServer.User = "test@emailarchitect.net" oServer.Password = "testpassword" ' Most mordern SMTP servers require SSL/TLS connection now. ' ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically. oServer.ConnectType = SmtpConnectType.ConnectTryTLS ' Request read receipt oMail.ReadReceipt = True ' Request both failure and success report oMail.DeliveryNotification = DeliveryNotificationOptions.OnFailure Or DeliveryNotificationOptions.OnSuccess Dim oSmtp As New SmtpClient() oSmtp.SendMail(oServer, oMail) Console.WriteLine("email was sent successfully!") Catch ep As Exception Console.WriteLine("failed to send email {0}", ep.Message) End Try End Sub

See Also

Process Bounced Email (Non-Delivery Report) and Email Tracking