class QQEmail { public bool IsSetEmail(string FromAddress, string ToAddress, string Message,string Pwd) { MailAddress Address = new MailAddress(FromAddress);// MailMessage mail = new MailMessage();// mail.SubjectEncoding = System.Text.Encoding.UTF8; mail.Subject = "这是" + FromAddress + "发送的一段信息:"; mail.BodyEncoding = System.Text.Encoding.UTF8; mail.Body =Message;// mail.IsBodyHtml = true; mail.Priority = System.Net.Mail.MailPriority.Low; mail.To.Add(ToAddress);// mail.From = Address; SmtpClient smtp = new SmtpClient("smtp.qq.com",25);//smtp支持的服务器是smtp.qq.com,服务器端口是25,587也行 smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.EnableSsl = true;// smtp.UseDefaultCredentials = false; smtp.Credentials = new System.Net.NetworkCredential( FromAddress,Pwd);//切记这两个数据一定要填对 try { smtp.Send(mail); return true; }catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return false; } } } }