Not Catch the SmtpFailedRecipientsException
-
MailAddress from = new MailAddress("nithya.d@demo.com"); MailAddress to = new MailAddress("nithydurai@gmai.com"); MailMessage message = new MailMessage(from, to); message.Subject = "hai dear"; message.Body = "Hello this is a test Mail"; message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.Delay; SmtpClient client = new SmtpClient("75.126.193.146"); // Include credentials if the server requires them. client.Credentials = new NetworkCredential("info@afxisi.net", "afxisi"); message.Headers.Add("Disposition-Notification-To", "nithya.d@afxisi.co.in"); //client.SendCompleted += new // SendCompletedEventHandler((this.SendCompleted)); Boolean bTemp = true; 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.InnerExceptions[i].FailedRecipient); } } } catch (SmtpException ex) { Response.Write(ex.ToString()); } catch (ObjectDisposedException ex) { Response.Write(ex.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } } } i send the wrong mail id... but this program not catch the SmtpFailedRecipientsException.... pls help me
-
MailAddress from = new MailAddress("nithya.d@demo.com"); MailAddress to = new MailAddress("nithydurai@gmai.com"); MailMessage message = new MailMessage(from, to); message.Subject = "hai dear"; message.Body = "Hello this is a test Mail"; message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.Delay; SmtpClient client = new SmtpClient("75.126.193.146"); // Include credentials if the server requires them. client.Credentials = new NetworkCredential("info@afxisi.net", "afxisi"); message.Headers.Add("Disposition-Notification-To", "nithya.d@afxisi.co.in"); //client.SendCompleted += new // SendCompletedEventHandler((this.SendCompleted)); Boolean bTemp = true; 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.InnerExceptions[i].FailedRecipient); } } } catch (SmtpException ex) { Response.Write(ex.ToString()); } catch (ObjectDisposedException ex) { Response.Write(ex.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } } } i send the wrong mail id... but this program not catch the SmtpFailedRecipientsException.... pls help me
First of all your code is broken. You copied the MSDN example directly into an ASP.NET page? A Console can't work on ASP.NET/web applications.
Navaneeth How to use google | Ask smart questions
-
First of all your code is broken. You copied the MSDN example directly into an ASP.NET page? A Console can't work on ASP.NET/web applications.
Navaneeth How to use google | Ask smart questions
i also download the MSDN code.... mail send perfectly but i send wrong mailid... i cannot capture the failure mailid
-
MailAddress from = new MailAddress("nithya.d@demo.com"); MailAddress to = new MailAddress("nithydurai@gmai.com"); MailMessage message = new MailMessage(from, to); message.Subject = "hai dear"; message.Body = "Hello this is a test Mail"; message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.Delay; SmtpClient client = new SmtpClient("75.126.193.146"); // Include credentials if the server requires them. client.Credentials = new NetworkCredential("info@afxisi.net", "afxisi"); message.Headers.Add("Disposition-Notification-To", "nithya.d@afxisi.co.in"); //client.SendCompleted += new // SendCompletedEventHandler((this.SendCompleted)); Boolean bTemp = true; 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.InnerExceptions[i].FailedRecipient); } } } catch (SmtpException ex) { Response.Write(ex.ToString()); } catch (ObjectDisposedException ex) { Response.Write(ex.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } } } i send the wrong mail id... but this program not catch the SmtpFailedRecipientsException.... pls help me
-
No sir how to define in web.config file
-
i also download the MSDN code.... mail send perfectly but i send wrong mailid... i cannot capture the failure mailid
Usually the mail-box unavailable or storage size exceeded kind of errors appear hours after you send the mail. This might be the reason that exception is not throwing. To test what I said, change the server to gmail(or whatever is the recipients mail server) and send the mail. Since both are in same server, I assume the exception can be raised by the
SmtpClient
class.Navaneeth How to use google | Ask smart questions
-
Usually the mail-box unavailable or storage size exceeded kind of errors appear hours after you send the mail. This might be the reason that exception is not throwing. To test what I said, change the server to gmail(or whatever is the recipients mail server) and send the mail. Since both are in same server, I assume the exception can be raised by the
SmtpClient
class.Navaneeth How to use google | Ask smart questions
can you give any example coding sir
-
can you give any example coding sir
The example which you got from MSDN is enough. All you have to do is change the server to a server where your recipients email exist.
Navaneeth How to use google | Ask smart questions
-
No sir how to define in web.config file
hi u can search this kind of issues from following links 1)http://www.dreamincode.net 2.)echoecho.com 3) w3schools.com plz let me know if u got the solution Thanks Jasjit Singh Jas