title: C# SmtpClient.Send() - Any alternative (or companion) to handling the exception?
body: <p>(Long time reader of SO, first time asking a q.</p>
  
  <p>I'm quite new to C# having been in the PHP/Ruby/Python world for many years so I apologise if this is a dopey question.)</p>
  
  <p>I'm doing some maintenance on an old C# app that is crashing whenever SmtpClient.Send() fails. From the little I've gleaned from the MSDN, I can see the obvious way to fix this, but my question is also concerned with the more general case.</p>
  
  <p>As per the MSDN:</p>
  
  <pre><code>  try {
            client.Send(message);
    }  
    catch (Exception ex) {
            Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", 
                  ex.ToString() );
    }
  </code></pre>
  
  <p>This all makes sense to me, but I've also always thought that whenever you can prevent the possibility of the error you do so. Is there anything you can (and should?) do here to reduce the possibility of the Send() throwing exceptions?</p>
  
  <p>I'm assuming there are situations where it's impossible to prevent the possibility of an exception, so you have to handle it, but are there any general style guide or rules that people use to guide them?</p>
  
  <p>Again, sorry if this is a crap question. I tried searching SO and Google as much as I could.</p>
  
  <p>EDIT: I just found this question <a href="https://stackoverflow.com/questions/409563/best-practices-for-exception-management-in-java-or-c">Best practices for exception management in java or C</a>
   which may well go someway to answering my question.</p>
  
  <p>EDIT2: Thanks for the prompt feedback, incredibly fast. I've been thinking about the problem a bit more and perhaps this could further refine what I'm asking.</p>
  
  <p>Is it correct to say that certain exceptions, like SmtpException, really can't be avoided? Is it even more correct to say that it is the correct style to use exceptions like SmtpException to tell you that something went wrong with the send and you just handle it however you'd like?</p>
  
  <p>I feel like I'm sounding a bit dim in this question, but I'm asking because anything I can learn is good for my confidence.</p>