你给我好好发邮件行不行

 


1
private void button1_Click(object sender, EventArgs e) 2 { 3 if (SendMail("07006@163.com", "27885@qq.com", "Hi 帮我在明天把书还了", "Hi,Cheers:明天下午帮我把书还了,谢谢!~"+DateTime.Now.ToString())) //调用发邮件方法。 4 { 5 Console.WriteLine("Send mail pass!"); 6 } 7 else 8 { 9 Console.WriteLine("Send mail fail!"); 10 } 11 } 12 13 public static bool SendMail(string from, string to, string subject, string body) 14 { 15 jmail.Message m = new jmail.Message(); 16 m.Charset = "gb2312"; 17 m.From = from; 18 m.Subject = subject; 19 m.AddRecipient(to, null, null); 20 m.MailServerUserName = "07006@163.com"; //此处为邮箱账户 21 #region password 22 m.MailServerPassWord = "******"; //此处为邮箱密码 23 #endregion 24 m.ContentType = "text/html"; 25 m.Body = body; 26 m.Send("smtp.163.com", false); 27 return true; 28 }

 

原文地址:https://www.cnblogs.com/leejunxu/p/2953550.html