从服务器发送电子邮件

时间:2011-02-06 22:54:01

标签: asp.net

这是我的代码,它无法在服务器上运行

try
{
   NetworkCredential loginInfo = new NetworkCredential("aaa", "aaa.a");
   MailMessage msg = new MailMessage();
   msg.From = new MailAddress("aaa@gmail.com");
   msg.To.Add(new MailAddress("aaa@gmail.com"));
   msg.Subject = " new costumer want to meet yue";
   msg.Body = TextBox1.Text + "<br />" + TextBox2.Text + "<br/>" + TextBox3.Text + "<br/>" + TextBox4.Text;
   msg.IsBodyHtml = true;
   SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
   client.EnableSsl = true;
   client.Credentials = loginInfo;
   client.Send(msg);
}
catch (Exception)
{
}

0 个答案:

没有答案