c#发送邮件功能实现


            SmtpClient smtp = new SmtpClient("smtp.163.com", 25);
            smtp.UseDefaultCredentials = true; //若服务器设置了smtp服务信息,则启用默认设置
            smtp.Credentials = new NetworkCredential("账号", "密码");//用于SMTP服务器的验证
            MailMessage msg = new MailMessage(
                "aa", //源邮件地址
                 "bb", //目的邮件地址
                  "xx", //发送邮件的标题
                "Hello world!" //发送邮件的内容
            );
            try
            {
                smtp.Send(msg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

posted @ 2014-11-20 15:21  除了影子  阅读(190)  评论(0编辑  收藏  举报