我有一項服務需要發送有關失敗的自動電子郵件。我覺得我有它設置了,但我一直收到以下錯誤:發送自動郵件
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