title: Sending out an automated email
body: <p>I have an service that needs to send out automated emails on failures. I feel like i have it set up but i keep on receiving the following error: </p>
  
  <pre><code>Service not available, closing transmission channel. The server response 
  was: 4.3.2 Service not available
  </code></pre>
  
  <p>I cant quite figure out where i went wrong, but here is my code:</p>
  
  <pre><code>public static void AutoEmail()
  {
      try
      {
          SmtpClient newClient = new SmtpClient();
          newClient.Host = "host name";
          newClient.Port = Port number;
          newClient.Credentials = new System.Net.NetworkCredential(
          "username", "password");
  
          MailMessage mail = new MailMessage();
          mail.To.Add(new MailAddress("something@email.com"));
          mail.Body = "This is a test message.";
          mail.Subject = "Test - " + DateTime.Now;
          mail.From = new MailAddress("something2@email.com");
  
          newClient.Send(mail);
      }
      catch (Exception ex)
      {
           Log.WriteException("Error in Email", ex);
      }
  }
  </code></pre>
  
  <p>Any help would be much appreciated. Thanks!</p>