我正在为我的最后一年项目建立一个酒店网站,我正在尝试在客户预订后向他们发送一封自动电子邮件。
使用此代码:
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.To.Add(email.Text);
message.Subject = "Hotel Reservation";
message.From = new System.Net.Mail.MailAddress("Reservation@hotel.com");
message.Body = ("Dear" + first_name.Text + "Your reservation made for " + rates.Text +" " + nor.Text + " " + "is successful. Please print out this email for reference while checkin. Thank you");
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost"); smtp.Send(message);
当我运行它时,它会显示此错误,突出显示smtp.Send(message); :
用户代码未处理 SmtpException 并且发送邮件失败。