SmtpClient发送邮件(用户找回密码)
-
-
-
-
-
-
-
-
-
-
-
-
- public static void SendEmailToUser(string stmpserver, string Mulitaddress, string attachmentName, string username,string pwd,string strfrom,string strto,string subject,string body)
- {
- SmtpClient smtp = new SmtpClient();
-
- smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
-
- smtp.Host = stmpserver;
-
- smtp.Port = 587;
-
- smtp.EnableSsl = true;
-
- smtp.Credentials = new System.Net.NetworkCredential(username, pwd);
-
-
- MailMessage _mailmessage = new MailMessage(strfrom, strto);
-
-
-
- if (!string.IsNullOrEmpty(Mulitaddress))
- {
-
- _mailmessage.Bcc.Add(Mulitaddress);
- }
-
-
-
- _mailmessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
-
- _mailmessage.Priority = MailPriority.High;
-
- _mailmessage.Subject = subject;
-
- if (!string.IsNullOrEmpty(attachmentName))
- {
- System.Net.Mail.Attachment attch = new System.Net.Mail.Attachment(attachmentName);
- _mailmessage.Attachments.Add(attch);
- }
-
- _mailmessage.SubjectEncoding = System.Text.Encoding.UTF8;
-
- _mailmessage.IsBodyHtml = true;
-
- _mailmessage.BodyEncoding = System.Text.Encoding.UTF8;
-
- _mailmessage.Body = body;
-
-
- try
- {
- smtp.Send(_mailmessage);
- }
- catch(Exception ex) {
- throw ex;
- }
-
- }
-
- string smtpserver = DBUtility.GetConfigVariable.GetConfigValue("smtpserver");
-
- string emailuserName = DBUtility.GetConfigVariable.GetConfigValue("emailuserName");
-
- string emailuserpwd = DBUtility.GetConfigVariable.GetConfigValue("emailuserpwd");
-
- string emailfrom = DBUtility.GetConfigVariable.GetConfigValue("emailfrom");
-
- string toUser =model.Email;
-
-
-
-
- string bodys = "亲爱的IT数码商城会员:" + model.Username + ":<br />您好!恭喜你己经找回密码";
- bodys+="你的密码是<b style="color;red" mce_style="color;red">"+model.Password+"</b>请妥善保管好你的密码!<br/>";
- bodys+="你可以通过http://www.ITWeb.cn/UserLogin.aspx/登录你的帐户!尽情享受IT数码城带给你的的乐趣吧!<br/>";
- bodys += "你也可以通过:http://www.ITWeb.cn/UpdateUserPwd.aspx/ 修改的你的密码!<br/>";
- bodys += "如果有任何疑问请联系管理员:QQ:664618843 Tel:13456946640<br/>";
- bodys += "请勿回复此邮件 谢谢合作!";
-
- DBUtility.SendEmail.SendEmailToUser(smtpserver, null, null, emailuserName, emailuserpwd, "luokuan2010@gmail.com", toUser, "IT数码城用户找回密码", bodys);
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
版权信息
原文地址:https://www.cnblogs.com/Leo_wl/p/1927564.html