title: Send email when using SmtpClient
body: <p>i have created loop of sending emails if they fail</p>
  
  <p>I have read that is not the best practise to have thread.sleep in code as this can lead to problems. However there is using for smtp client, which dispose of the transaction before the message is send. How can i make this better this is going to be used in web application?</p>
  
  <pre><code>using (var SmtpClient = new SmtpClient()) {
      bool success = false;
      int attemts = 0;
      const int maxAttempts = 5;
      do {
          try {
              SmtpClient.Send(mailMessage);
              System.Threading.Thread.Sleep(400);
              success = true;
          } catch{
              // ok wait for request
              success = false;
              attemts ++;
          }
      } while (success &amp;&amp; (attemts == maxAttempts));
  }
  </code></pre>