码迷,mamicode.com
首页 > Windows程序 > 详细

C#发送QQ邮件

时间:2014-12-31 09:56:53      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

  /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="title">邮箱内容</param>
        /// <param name="Email">邮箱地址</param>
        /// <param name="value">收件人姓名</param>
        /// <returns></returns>
        public string Small(string value,string Email,string title)
        {
            MailMessage mail;
            SmtpClient client;
            string EmailTitle = "877600684@qq.com";
            mail = new MailMessage(EmailTitle,Email);
            mail.Body = value;//内容
            mail.Subject = title;//标题
            mail.IsBodyHtml = true;
            mail.SubjectEncoding = System.Text.Encoding.Default;
            mail.BodyEncoding = System.Text.Encoding.Default;
            //mail.Headers.Add("X-Priority", "3");
            //mail.Headers.Add("X-MSMail-Priority", "Normal");
            //mail.Headers.Add("X-Mailer", "Microsoft Outlook Express 6.00.2900.2869");
            //mail.Headers.Add("X-MimeOLE", "Produced By Microsoft MimeOLE V6.00.2900.2869");
            client = new SmtpClient("smtp.qq.com");
            client.Credentials = new System.Net.NetworkCredential("用户名", "密码");
         //   client.Host = "smtp.qq.com";
            //System.Net.NetworkCredential crea = new System.Net.NetworkCredential();
            //crea.UserName = "用户名";
            //crea.Password = "密码";
              System.IO.StreamWriter writer = new System.IO.StreamWriter("D:\\log.txt", true);
            try {
                client.Send(mail);
                //发送成功
                writer.WriteLine("邮件发送成功");
                writer.Close();
                return "0";
                
            }
            catch (Exception e)
            {
                writer.WriteLine("邮件发送失败,错误信息:"+e.ToString());
                writer.Close();
                return "1";
            }
        }

 

C#发送QQ邮件

标签:

原文地址:http://www.cnblogs.com/xuemykisskui/p/4195012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!