.net 发送邮件

  public void sendMail2()
        {

            SmtpClient _smtpClient = new SmtpClient(); //smtp验证类

            _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
            _smtpClient.Host = "smtp.163.com";//指定SMTP服务器
            _smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "*****");
         
            MailMessage _mailMessage = new MailMessage("[email protected]", "[email protected]");
            _mailMessage.Subject = "title";//主题
            _mailMessage.Body = "content";//内容
            _mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//正文编码
           _mailMessage.IsBodyHtml = true;//设置为HTML格式
           _mailMessage.Priority = MailPriority.High;//优先级

            _smtpClient.Send(_mailMessage); //发送邮件
        }
using System.Net.Mail;

你可能感兴趣的:(.net)