我有一项服务需要发送有关失败的自动电子邮件。我觉得我有它设置了,但我一直收到以下错误:发送自动邮件
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("[email protected]"));
mail.Body = "This is a test message.";
mail.Subject = "Test - " + DateTime.Now;
mail.From = new MailAddress("[email protected]");
newClient.Send(mail);
}
catch (Exception ex)
{
Log.WriteException("Error in Email", ex);
}
}
任何帮助将非常感谢。谢谢!
此时你得到的例外? – Rohit
一旦它碰到说'newClient.Send(mail);'的行,就会触发catch。 – scapegoat17
可能的重复[服务器响应是:4.3.2服务不可用,关闭传输通道](http://stackoverflow.com/questions/12732859/the-server-response-was-4-3-2-service- not-available-closing-transmission-chann) – DaveShaw