G
Guest
I have an application that uses SmtpMail.
As part of that, I want a notification emailed to the sender on any failure.
I am using:
Dim SmtpMail As Mail.SmtpClient = New
System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings("strSmtpServer"))
Dim MyMail As System.Net.Mail.MailMessage
(code to populate To, From etc)
MyMail.DeliveryNotificationOptions =
Mail.DeliveryNotificationOptions.OnFailure
SmtpMail.Send(MyMail)
Which works great except on internal emails on the local Exchange server, in
which case an exception gets thrown (Mailbox unavailable. The server
response was: 5.1.1 User unknown) but the email gets sent anyway. Is there
anyway to suppress this exception, and have a notification email sent instead
like it does on an external email that is not valid?
Thanks.
As part of that, I want a notification emailed to the sender on any failure.
I am using:
Dim SmtpMail As Mail.SmtpClient = New
System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings("strSmtpServer"))
Dim MyMail As System.Net.Mail.MailMessage
(code to populate To, From etc)
MyMail.DeliveryNotificationOptions =
Mail.DeliveryNotificationOptions.OnFailure
SmtpMail.Send(MyMail)
Which works great except on internal emails on the local Exchange server, in
which case an exception gets thrown (Mailbox unavailable. The server
response was: 5.1.1 User unknown) but the email gets sent anyway. Is there
anyway to suppress this exception, and have a notification email sent instead
like it does on an external email that is not valid?
Thanks.