.net发邮件(测试成功)

private void SendEmail(String sender, String TransmitName, String Receiver, String subject, String Content)
{
MailMessage Mail = new MailMessage();
Mail.From = new MailAddress(sender);//发送人
Mail.To.Add(new MailAddress(Receiver));//接收人
Mail.IsBodyHtml = true;
Mail.Subject = subject;
Mail.IsBodyHtml = true;
Mail.Body = Content;
SmtpClient sc = new SmtpClient();
string EmailServer = System.Configuration.ConfigurationManager.AppSettings["EmailServer"];//服务器
sc.Host = EmailServer;
sc.UseDefaultCredentials = false;
string pwdEmail = System.Configuration.ConfigurationManager.AppSettings["pwdEmail"];//密码
sc.Credentials = new NetworkCredential(TransmitName, pwdEmail);
sc.DeliveryMethod = SmtpDeliveryMethod.Network;
sc.Send(Mail);

}
posted @ 2012-02-14 11:27  ~随风~  阅读(135)  评论(0编辑  收藏  举报