none
Debugging SmtpClient RRS feed

  • Question

  • How should I go about debuggin SmtpClient for email use in C#

    code? If the attempt to send email failes and I catch the

    exception thrown, how shuold I code the catch block to decide

    what went wrong?

    public static bool SendEmail(MailMessage Mail, int Attempt) { if (Attempt <= 3) { SmtpClient smtp = new SmtpClient(); try { smtp.Send(Mail); return true; } catch (Exception ex) { Thread.Sleep(3000); // pause for three seconds and try again Attempt = Attempt + 1; SendEmail(Mail, Attempt); } } return false; }

    How should I go about debuggin SmtpClient for email use in C#

    code?  If the attempt to send email failes and I catch the

    exception thrown, how shuold I code the catch block to decide

    what went wrong?



    • Edited by Bobby Lawrence Wednesday, April 10, 2013 5:11 PM added text outside code block
    • Moved by Bob Shen Friday, April 12, 2013 9:08 AM
    Wednesday, April 10, 2013 5:09 PM

All replies