zoukankan      html  css  js  c++  java
  • C#发送QQ邮件

      /// <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";
                }
            }
    

     

  • 相关阅读:
    她又在这个星期联系我了 20110422
    用心去做 20110307
    2011年随笔记
    让我有勇气坚持下去 20110427
    2011年随笔记 5月30号以后的日志薄
    因为迷失,所以 201103015
    迷失只是暂时 20110313
    我们做一对好哥们吧 20101228
    3.20号,她恢复了联系 20110320
    FW: Deploy reporting services web parts (RSWebParts) to SharePoint 2010
  • 原文地址:https://www.cnblogs.com/xuemykisskui/p/4195012.html
Copyright © 2011-2022 走看看