// 首先开启smtp服务 try { MailMessage message = new MailMessage(); SmtpClient smtp = new SmtpClient(); message.From = new MailAddress("from@domain.com"); message.To.Add(new MailAddress("to@domain.com")); message.Subject = "Subject"; message.Body = "Hello World"; smtp.Port = 587; smtp.Host = "smtp.domain.com"; smtp.EnableSsl = true; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("from@domain.com", "password"); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Send(message); } catch (Exception ex) { Console.WriteLine(ex.Message); }