title: Check if SMTP is running or failed to send email
body: <p>I am using SMTP server to send emails.
  I would like to get an error message when the SMTP server is down or when the email was not delivered.<br>
  With DeliveryNotificationOptions.OnFailure I get an email that the email has not been delivered.<br>
  I would like to get an error. Is this possible?<br>
  How I can check if SMTP is running?</p>
  
  <p>Here is the code I use:</p>
  
  <pre><code>Dim serverName As String = ""
  Dim mailSenderInstance As SmtpClient = Nothing
  Dim AnEmailMessage As New MailMessage
  Dim sendersEmail As String = ""
  Try
      serverName = GetServerName("EMAIL_SERVER")
      mailSenderInstance = New SmtpClient(serverName, 25)
      sendersEmail = GetSendersEmail(msUserName)
      AnEmailMessage.From = New MailAddress(sendersEmail)
  
     'MAIL DETAILS
      AnEmailMessage.Subject = "New Email"
      AnEmailMessage.Body = "The Message"
      AnEmailMessage.To.Add(anEmailAddress)
  
      ' Delivery notifications
      AnEmailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
      mailSenderInstance.UseDefaultCredentials = True 'False
      mailSenderInstance.Send(AnEmailMessage)
  
  Catch ex As System.Exception
      MessageBox.Show(ex.ToString)
  Finally
      AnEmailMessage.Dispose()
      mailSenderInstance.Dispose() 
  End Try
  </code></pre>