/// <summary> /// 向用户发送邮件 /// </summary> /// <param name="ReceiveMail">接收人,邮箱地址</param> /// <param name="ReceiveName">接收人,显示的名称</param> /// <param name="SendMail">发件人,邮箱地址</param> /// <param name="SendDisplayName">发件人,显示的名称</param> /// <param name="AtuhCode">发件人,邮箱授权码</param> /// <param name="MailTitle">邮件标题</param> /// <param name="MailContent">邮件内容</param> private void SendMail(string ReceiveMail, string SendMail, string SendDisplayName, string AtuhCode, string MailTitle, string MailContent) { try { MailAddress toMail = new MailAddress(ReceiveMail); MailAddress fromMail = new MailAddress(SendMail, SendDisplayName); MailMessage mail = new MailMessage(fromMail, toMail); mail.Subject = MailTitle; mail.IsBodyHtml = true; mail.Body = MailContent; SmtpClient client = new SmtpClient(); client.EnableSsl = true; client.Host = "smtp.exmail.qq.com"; client.Port = 25; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(SendMail, AtuhCode); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Send(mail); } catch (Exception ex) { _logger.LogError($"邮件发送异常,异常信息:{ex.ToString()}"); } }
标签:短信,string,SendMail,new,发送,client,腾讯,mail,MailAddress From: https://www.cnblogs.com/dayang12525/p/17178671.html