如何使用asp.net中的联系表单向指定的电子邮件地址发送电子邮件?该网站通过托管公司托管。感谢
答案 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);