Delivery status notification (DSN) is an extension added to SMTP to extend the types of and situations when the sender will be notified of the status of a send message. With PowerTCP Mail for .NET delivery status notification is managed by use of the DeliveryStatusNotification class, accessible via the DSN property. Simple set the properties of the DeliveryStatusNotification class, and, if the mail server supports DSN, any necessary communication will automatically occur.
To quickly and easily send a message with DSN.
- Add the Smtp component to a new form.
- Import the namespace of the component you would like to use using "Using" (C#) or "Imports" (VB.NET). Place the following code at the top of your file.
C#
Copy Codeusing Dart.PowerTCP.Mail;Visual Basic
Copy CodeImports Dart.PowerTCP.Mail - Add a button to the form.
- Specify your SMTP mail server. Do this by setting the Server property. The following code demonstrates setting the Server property. For the purposes of this walk-through, simply put this code in the click event of the button you added to the form in step 3.
C#
Copy Codesmtp1.Server = "mail.myserver.com";Visual Basic
Copy CodeSmtp1.Server = "mail.myserver.com" - Set the properties of the DeliveryStatusNotification class. Put this code in the click event of the button you added to the form in step 1.
C#
Copy Code// The EnvelopeID will be returned as the "Original-Envelope-ID" header in the DSN smtp1.DSN.EnvelopeID = "QQ314159"; // Return the entire message instead of only the headers. smtp1.DSN.ReturnMessage = true; // Send a DSN on success, failure, or delay (this property is additive). smtp1.DSN.Type = DSNType.Failure+DSNType.Success+DSNType.Delay;
Visual Basic
Copy Code' The EnvelopeID will be returned as the "Original-Envelope-ID" header in the DSN Smtp1.DSN.EnvelopeID = "QQ314159" ' Return the entire message instead of only the headers. Smtp1.DSN.ReturnMessage = True ' Send a DSN on success, failure, or delay (this property is additive). Smtp1.DSN.Type = DSNType.Failure+DSNType.Success+DSNType.Delay
- Use the Send method to send a quick message. The following code demonstrates the use of the Send method to send a quick text message. Place this code directly after the code from step 5.
C#
Copy Codesmtp1.Send("you@test.com", "me@test.com", "Test", "This is a test message!");
Visual Basic
Copy CodeSmtp1.Send("you@test.com", "me@test.com", "Test", "This is a test message!")
- Compile and run the application.