我有一项服务需要在失败时自动发送电子邮件。我觉得我已经设置了它,但我不断收到以下错误:
Service not available, closing transmission channel. The server response
was: 4.3.2 Service not available
我无法弄清楚我哪里出错了,但这是我的代码:
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);
}
}
任何帮助将非常感激。谢谢!