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

     

  • 相关阅读:
    Linux基础ls命令
    Linux基础tree命令
    Java银行调度系统
    Java交通灯系统
    Java反射
    Java基础IO流
    Java多线程
    Java集合框架
    Springmvc的一些属性功能
    JS
  • 原文地址:https://www.cnblogs.com/xuemykisskui/p/4195012.html
Copyright © 2020-2023  润新知