首页 > 代码库 > 亲测可用的发送邮件方法分享

亲测可用的发送邮件方法分享

//发送邮件代码
  public static void Sends(string email, string formto, string content, string body, string upass)
     {
         string name = "no_reply@xxxx.com"; 
         string smtp = "smtp.exmail.sina.com";
         SmtpClient _smtpClient = new SmtpClient();
         _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
         _smtpClient.Host = smtp; 
         _smtpClient.Credentials = new System.Net.NetworkCredential(name, upass);
         MailMessage _mailMessage = new MailMessage();
         _mailMessage.From = new MailAddress(formto, "xxxx公司");
         _mailMessage.To.Add(email);
         _mailMessage.SubjectEncoding = System.Text.Encoding.GetEncoding("gb2312");
         _mailMessage.Subject = content;
         _mailMessage.Body = body;
         _mailMessage.BodyEncoding = System.Text.Encoding.GetEncoding("gb2312");
         _mailMessage.IsBodyHtml = true;
         _mailMessage.Priority = MailPriority.High;  
      }

注:formto需为真实的邮箱地址

亲测可用的发送邮件方法分享