我正在尝试通过在 hostgator 中创建 dotnetnuke 模块来发送邮件,但邮件不起作用。请给我任何有用的建议。
protected void btnSubmit_Click(object sender, EventArgs e)
{
string Fname = txtFname.Text;
string Lname = txtLname.Text;
string Email = txtEmail.Text;
string Telephone = txtTelephone.Text;
string comments = txtComments.Text;
MailMessage newmail = new MailMessage(ConfigurationManager.AppSettings["FromEmailHelpForm"].ToString(), ConfigurationManager.AppSettings["ToEmailHelpForm"].ToString());
newmail.Subject = "Contact Form Notification";
newmail.IsBodyHtml = true;
newmail.Body = "<table><tr><td>First Name:<td><td>' " + Fname + " '</td><tr><tr><td>Last Name:<td><td>' " + Lname + " '</td><tr><tr><td>Primary Email Address: <td><td>' " + Email + " '</td><tr><tr><td>Telephone: <td><td>' " + Telephone + " '</td><tr><tr><td>Comments: <td><td>' " + comments + " '</td><tr></table>";
SmtpClient mail = new SmtpClient("localhost");
try
{
if (CaptchaControl1.IsValid)
{
mail.Send(newmail);
reset();
pnlMessage.Visible = true;
pnlform.Visible = false;
lblError.Text = "Thankyou for submiting the form we will get you soon";
lblError.ForeColor = System.Drawing.Color.Blue;
}
else
{
lblError.Text = "Invalid Security Code ";
lblError.ForeColor = System.Drawing.Color.Red;
}
}
catch (Exception err)
{
lblError.Text = "An error Occured -->"+err.Message;
lblError.ForeColor = System.Drawing.Color.Red;
}
}
public void reset()
{
txtFname.Text = "";
txtLname.Text = "";
txtTelephone.Text = "";
txtEmail.Text = "";
txtComments.Text = "";
}
}