Recebendo Notificações para Mensagens Enviadas com Sucesso e Mensagens Falhadas
Contents
[
Hide
]
Quando você deseja receber a notificação de entrega para mensagens enviadas com sucesso e para mensagens falhadas, pode usar o operador pipe (|) para a propriedade DeliveryNotificationOptions da classe MailMessage. O seguinte trecho de código mostra como receber notificações para mensagens enviadas com sucesso e mensagens falhadas.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Create the message | |
MailMessage msg = new MailMessage(); | |
msg.From = "sender@sender.com"; | |
msg.To = "receiver@receiver.com"; | |
msg.Subject = "the subject of the message"; | |
// Set delivery notifications for success and failed messages and Add the MIME headers | |
msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.OnFailure; | |
msg.Headers.Add("Read-Receipt-To", "sender@sender.com"); | |
msg.Headers.Add("Disposition-Notification-To", "sender@sender.com"); | |
// Send the message | |
SmtpClient client = new SmtpClient("host", "username", "password"); | |
client.Send(msg); |