我在一个不起作用的 aspx 页面上有一个快速联系表单我正在使用 try/catch 块以防出现异常,直到现在只有 catch 工作。请帮助我使用邮件消息类的代码System.Net.Mail 命名空间的。她的代码
try
{
MailMessage EmailMsg = new MailMessage();
EmailMsg.From = new MailAddress(txtEmail.Text,txtName.Text);
EmailMsg.To.Add(new MailAddress("mail address"));
EmailMsg.Subject = "WebAssist Email form";
EmailMsg.Body = "<html><body>This is a text<hr>Test test</body></html>";
EmailMsg.IsBodyHtml = true;
EmailMsg.Priority = MailPriority.Normal;
SmtpClient MailClient = new SmtpClient("");
MailClient.EnableSsl = true;
MailClient.Credentials = new System.Net.NetworkCredential("","");
MailClient.Send(EmailMsg);
Label1.Visible = true;
Label1.Text = "Email sent";
}
catch
{
Label1.Visible = true;
Label1.Text = "Your email was not sent";
}
请告诉在 smtp 构造函数中要写什么,在网络凭据中提前谢谢