Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Not Catch the SmtpFailedRecipientsException

Not Catch the SmtpFailedRecipientsException

Scheduled Pinned Locked Moved ASP.NET
csharpcomsysadminhelp
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nithydurai
    wrote on last edited by
    #1

    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

    N J 2 Replies Last reply
    0
    • N nithydurai

      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

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • N N a v a n e e t h

        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

        N Offline
        N Offline
        nithydurai
        wrote on last edited by
        #3

        i also download the MSDN code.... mail send perfectly but i send wrong mailid... i cannot capture the failure mailid

        N 1 Reply Last reply
        0
        • N nithydurai

          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

          J Offline
          J Offline
          Jas 007
          wrote on last edited by
          #4

          have u define web.config file

          N 1 Reply Last reply
          0
          • J Jas 007

            have u define web.config file

            N Offline
            N Offline
            nithydurai
            wrote on last edited by
            #5

            No sir how to define in web.config file

            J 1 Reply Last reply
            0
            • N nithydurai

              i also download the MSDN code.... mail send perfectly but i send wrong mailid... i cannot capture the failure mailid

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              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

              N 1 Reply Last reply
              0
              • N N a v a n e e t h

                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

                N Offline
                N Offline
                nithydurai
                wrote on last edited by
                #7

                can you give any example coding sir

                N 1 Reply Last reply
                0
                • N nithydurai

                  can you give any example coding sir

                  N Offline
                  N Offline
                  N a v a n e e t h
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • N nithydurai

                    No sir how to define in web.config file

                    J Offline
                    J Offline
                    Jas 007
                    wrote on last edited by
                    #9

                    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

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups