标签:
/// <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"; } }
标签:
原文地址:http://www.cnblogs.com/xuemykisskui/p/4195012.html