发送到联系表格asp.net的电子邮件

时间:2011-02-19 05:31:26

标签: asp.net

如何使用asp.net中的联系表单向指定的电子邮件地址发送电子邮件?该网站通过托管公司托管。感谢

1 个答案:

答案 0 :(得分:1)

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("your.mail.server");

mail.From = new MailAddress("your_email_address@gmail.com");
mail.To.Add("to_address@mfc.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail";

SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");

SmtpServer.Send(mail);