首页 > 代码库 > C#发送QQ邮件
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"; } }
C#发送QQ邮件
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。