标签:方式 stat word eva 正文 sys point sage tp服务器
public static int SendEmail(string mailContent, string mailSubject, string mailTo) { // 设置例网易的smtp string smtpServer = "smtp.qq.com";// "14.18.245.164"; //SMTP服务器 string mailFrom = "XXXX@qq.com"; //登陆用户名 string userPassword = "XXXXXXXXX";//登陆密码 // 邮件服务设置 SmtpClient smtpClient = new SmtpClient(); smtpClient.EnableSsl = true; smtpClient.UseDefaultCredentials = false; smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式 smtpClient.Host = smtpServer; //指定SMTP服务器 smtpClient.Timeout = 5000; smtpClient.Port = 587; smtpClient.Credentials = new System.Net.NetworkCredential(mailFrom, userPassword);//用户名和密码 MailMessage mailMessage = new MailMessage(mailFrom, mailTo); // 发送人和收件人 mailMessage.Subject = mailSubject;//主题 mailMessage.Body = mailContent;//内容 mailMessage.BodyEncoding = Encoding.UTF8;//正文编码 mailMessage.IsBodyHtml = true;//设置为HTML格式 mailMessage.Priority = MailPriority.Low;//优先级 try { ServicePointManager.ServerCertificateValidationCallback = delegate (Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; }; smtpClient.Send(mailMessage); // 发送邮件 return 1; } catch (SmtpException ex) { Logger.Create("- 邮件发送异常", ex.ToString()); return 0; } }
标签:方式 stat word eva 正文 sys point sage tp服务器
原文地址:https://www.cnblogs.com/lgq168/p/11515603.html