我向我的用户发送确认email
,当他们单击它时,他们的帐户将变为活动状态。我唯一想要的是在 48 小时后使链接失效,并且用户可以再次注册username
。有谁能够帮助我?这是我的电子邮件代码:
Session["UserName"] = TextBox_email.Text;
MailMessage msg = new MailMessage();
StringBuilder bodyMsg = new StringBuilder();
MembershipUser user = Membership.CreateUser(TextBox_email.Text, TextBox_Pass.Text, TextBox_email.Text);
Roles.AddUserToRole(TextBox_email.Text, "Author");
user.IsApproved = false;
Membership.UpdateUser(user);
// StringBuilder bodyMsg = new StringBuilder();
Guid userID = (Guid)user.ProviderUserKey;
msg.Subject = "Submission Confirmation";
bodyMsg.Append("<html><head><img src=" + "http://waag.ir/images/header.jpg" + ">" + "<title>CONFIRMATION EMAIL:</title></head><body>");
bodyMsg.Append("<br/>");
string link = string.Format("http://www.waag.ir/Activate.aspx?userID={0}", userID.ToString());
bodyMsg.Append("Dear " + RadioButtonList_Prefix.SelectedItem.Text + " " + name.Text + " " + middle.Text + " " + lastname.Text + ":<br> Thank you for registering with Avestia Publishing manuscript submission system. To confirm and complete your registration, please follow the link below:</br>" + link + "</br>This link is active for 48 hours. If the link is not visited within this time frame, your registration will be discarded and you will need to register again.</br></br></br>Best regards,</br>Avestia Publishing</br>http://avestia.com");
msg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
msg.Priority = MailPriority.High;
msg.Body = bodyMsg.ToString();
msg.IsBodyHtml = true;
msg.BodyEncoding = System.Text.Encoding.GetEncoding("utf-8");
msg.Priority = MailPriority.High;
// msg.ReplyTo = new MailAddress(TextBox2.Text);
msg.From = new MailAddress("goldenstudio@goldenstudio.ir");
msg.To.Add(new MailAddress(TextBox_email.Text));
SmtpClient mailsender = new SmtpClient();
mailsender.Host = "SmtpClient.goldenstudio.ir";
mailsender.Port = 587;
mailsender.EnableSsl = true;
mailsender.Credentials = new System.Net.NetworkCredential("goldenstudio@goldenstudio.ir", "classaspnet");
SmtpClient smtp = new SmtpClient();
//Literal1.Text = "<script>alert(' ')</script>";
smtp.Send(msg);