以下是我用smtp服務器發送電子郵件的編碼。但它會拋出smtpexception作爲發送失敗。發送電子郵件不適用於我的smtp服務器
我正在使用Windows Web服務器爲我的網站。
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress(txtEmail.Text);
// Recipient e-mail address.
Msg.To.Add("[email protected]");
Msg.Subject = txtSubject.Text;
Msg.Body = txtMessage.Text;
Msg.IsBodyHtml = true;
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "mail.dhuvara.com";
smtp.Port = 25;
Msg.Priority = MailPriority.Normal;
smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "SolaiMail");
smtp.EnableSsl = true;
smtp.Send(Msg);
//Msg = null;
lbltxt.Text = "Thanks for Contact us";
// Clear the textbox valuess
txtName.Text = "";
txtSubject.Text = "";
txtMessage.Text = "";
txtEmail.Text = "";
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
異常包含超過類名稱。什麼是*消息*? –
你可以粘貼異常消息嗎? –
「發送郵件失敗。」這是我的代碼中的異常消息。 – baskaran