发送邮件代码

 1 public class EmailHelper
 2     {
 3         /// <summary>
 4         /// 发送邮件
 5         /// </summary>
 6         /// <param name="sendAddress">发件人地址</param>
 7         /// <param name="sendPwd">发件人邮箱密码</param>
 8         /// <param name="receiveAddress">收件人地址</param>
 9         /// <param name="content">邮件内容</param>
10         public static void SendEmail(string sendAddress,string sendPwd, string receiveAddress, string content)
11         {
12             var mailMessage = new MailMessage();
13             mailMessage.From=new MailAddress(sendAddress);
14             mailMessage.To.Add(new MailAddress(receiveAddress));
15             mailMessage.Subject = "测试主题";
16             mailMessage.IsBodyHtml = true;
17             mailMessage.BodyEncoding=Encoding.UTF8;
18             mailMessage.Body = content;
19             mailMessage.Priority=MailPriority.Normal;
20             var client=new SmtpClient("smtp.qq.com");
21             client.Credentials = new NetworkCredential(sendAddress, sendPwd);
22             client.EnableSsl = true;
23             client.Send(mailMessage);
24         }
25     }

 

posted @ 2015-08-31 16:41  孤独的十字  阅读(399)  评论(0编辑  收藏  举报