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. General Programming
  3. C#
  4. how to handle the System.Web.Mail Exceptions effectively.?

how to handle the System.Web.Mail Exceptions effectively.?

Scheduled Pinned Locked Moved C#
csharptutorialquestion
3 Posts 2 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.
  • S Offline
    S Offline
    sundar156
    wrote on last edited by
    #1

    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.

    K 1 Reply Last reply
    0
    • S sundar156

      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.

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • K kubben

        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

        S Offline
        S Offline
        sundar156
        wrote on last edited by
        #3

        but this is possible only in .net Framework 2.0 ...I am currently using .net Framework 1.1...!

        people laugh at me because they say im different and I laugh at them because they are all the same.

        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