在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
/// <summary> /// 发送邮件 发送激活码 /// </summary> /// <param name="address">接受者地址</param> /// <param name="displayName">接收者姓名</param> /// <param name="signString">激活码</param> public static void RegionSendEmail(string address, string displayName, string signString, string userName)//发激活码邮件部分 { try { Encoding encoding = Encoding.GetEncoding("utf-8"); Configuration config = WebConfigurationManager.OpenWebConfiguration("~/web.config"); MailSettingsSectionGroup settings = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings"); MailAddress from = new MailAddress(settings.Smtp.From, settings.Smtp.Network.UserName, encoding); MailAddress to = new MailAddress(address, displayName, encoding); MailMessage message = new MailMessage(from, to); message.SubjectEncoding = encoding; message.IsBodyHtml = true; message.Priority = MailPriority.High; message.Subject = "XXXXX邮箱验证激活"; message.BodyEncoding = encoding; StringBuilder sb = new StringBuilder(); sb.Append("您好:"); sb.Append(userName); sb.Append("<br/>请点击下面的连接来验证激活"); sb.Append(string.Format("<br/><a href='http://baidu.com/Index/CheckingEmailBack.aspx?SignString={0}&userName={1}'>", signString, userName)); sb.Append(string.Format("http://baidu.com/Index/CheckingEmailBack.aspx?SignString={0}&userName={1}", signString, userName)); sb.Append("</a>"); //邮件主体 message.Body = sb.ToString(); //服务器 SmtpClient client = new SmtpClient(settings.Smtp.Network.Host); //的用户名和密码 client.Credentials = new NetworkCredential(settings.Smtp.From, settings.Smtp.Network.Password); client.Send(message); } catch (Exception ex) { throw new Exception(ex.Message); } }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论