how to handle the System.Web.Mail Exceptions effectively.?
-
hi , I'm using .net 1.1 and have t send mail using System.Web.Mail.I have to handle errors like when the message sending fails i have to resend the mail,If the address is invalid i should not resend it again and if the mail bounce due to mailbox full,i have to resend it..Is it possible if i use System.Web.Mail. I know this can be handed in .Net 2.0 using System.Net.mail.
people laugh at me because they say im different and I laugh at them because they are all the same.
-
hi , I'm using .net 1.1 and have t send mail using System.Web.Mail.I have to handle errors like when the message sending fails i have to resend the mail,If the address is invalid i should not resend it again and if the mail bounce due to mailbox full,i have to resend it..Is it possible if i use System.Web.Mail. I know this can be handed in .Net 2.0 using System.Net.mail.
people laugh at me because they say im different and I laugh at them because they are all the same.
There are two differnet kinds of exceptions you can check for. SmtpFailedRecipientsException SmtpFailedRecipientException SmtpException Microsoft help has this example: try { client.Send(message); } catch (SmtpFailedRecipientsException ex) { for (int i = 0; i < ex.InnerExceptions.Length; i++) { SmtpStatusCode status = ex.InnerExceptions[i].StatusCode; if (status == SmtpStatusCode.MailboxBusy || status == SmtpStatusCode.MailboxUnavailable) { Console.WriteLine("Delivery failed - retrying in 5 seconds."); System.Threading.Thread.Sleep(5000); client.Send(message); } else { Console.WriteLine("Failed to deliver message to {0}", ex.FailedRecipient[i]); } } } Hope that helps. Ben
-
There are two differnet kinds of exceptions you can check for. SmtpFailedRecipientsException SmtpFailedRecipientException SmtpException Microsoft help has this example: try { client.Send(message); } catch (SmtpFailedRecipientsException ex) { for (int i = 0; i < ex.InnerExceptions.Length; i++) { SmtpStatusCode status = ex.InnerExceptions[i].StatusCode; if (status == SmtpStatusCode.MailboxBusy || status == SmtpStatusCode.MailboxUnavailable) { Console.WriteLine("Delivery failed - retrying in 5 seconds."); System.Threading.Thread.Sleep(5000); client.Send(message); } else { Console.WriteLine("Failed to deliver message to {0}", ex.FailedRecipient[i]); } } } Hope that helps. Ben