c#发送邮件

            MailMessage mailMsg = new MailMessage();
            mailMsg.From = new MailAddress("发送人邮箱帐号", "发送人昵称");
            mailMsg.To.Add(new MailAddress("收件人地址", "收件人昵称"));
            mailMsg.Subject = txtTitle.Text;//标题
            mailMsg.Body = txtMail.Text;
            mailMsg.IsBodyHtml = true;//正文可以为html
            mailMsg.BodyEncoding = Encoding.GetEncoding("GB2312");
            SmtpClient client = new SmtpClient("smtp.live.com");//发送邮箱服务器
            client.EnableSsl = true;//要求安全连接的,hotmail需要,网易,QQ不用
            client.Credentials = new NetworkCredential("发送人的账号", "发送人的密码");
            client.Send(mailMsg);
posted on 2013-04-11 17:46  快乐于行  阅读(165)  评论(0编辑  收藏  举报