我正在尝试在 asp.net 中使用 SMTP 发送电子邮件。以下代码不起作用。
public string send_email(string name, string email, string message)
{
var fromAddress = email;
var toAddress = "ashish_sharma307@hotmail.com";
string subject = "Feedback";
string body = "From: " + name+ "\n";
body += "Email: " + email + "\n";
body += "Subject: " + subject + "\n";
body += "Question: \n" + message + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.live.com";
smtp.Port = 587;
}
smtp.Send(fromAddress, toAddress, subject, body);
return "Your query has been submitted.";
}
这没有按预期工作。我正在尝试从反馈表中发送电子邮件。