简体   繁体   English

单击后如何使禁用或不可见的电子邮件链接生效,我该如何使用常规的smtp服务器?

[英]how to make disable or unvisible email link when the it is clicked, also, how can i use general smtp server?

I tried some codes but after it is send to mail account, it is always the active how can it become passive link . 我尝试了一些代码,但是将其发送到邮件帐户后,它始终是主动的,如何成为被动的链接。

                   string UName = GetNewValidationCode();
                    // Now lets create an email message
                    SmtpClient SmtpServer = new SmtpClient("smtp.live.com");

        var mail = new MailMessage();
        mail.From = new MailAddress("bilkentliaslan@windowslive.com");
        mail.To.Add(TextBox6.Text);
        mail.Subject = "Registration";
        mail.IsBodyHtml = true;
        string htmlBody;
        htmlBody = string.Format("Thank you for creating an account with YourDomain.com</ br>"+"Please click the below link to activate your account <br />"+"<a href='http://localhost:2386/ActivateUser.aspx?userName{0}&Id={1}'>Activate {0} </a>", UName, user_name);
        mail.Body = htmlBody;

        SmtpServer.Port = 587;
        SmtpServer.UseDefaultCredentials = false;
        SmtpServer.Credentials = new System.Net.NetworkCredential("bilkentliaslan@windowslive.com", "my password");
        SmtpServer.EnableSsl = true;
        SmtpServer.Send(mail);

                    // Redirecto to What ever page
                    Response.Redirect("Login.aspx");

Keep a table that stores the waiting IDs, ie, the IDs that you have sent an email about, but which are not yet activated. 保留一个表,该表存储等待的ID,即您发送电子邮件的ID,但尚未激活。

Then in the code of your ActivateUser.aspx (actually in the back-end code that that page then calls), check if the row exists, perform the user activation work and then remove the row from the table. 然后,在ActivateUser.aspx的代码中(实际上在该页面随后调用的后端代码中),检查该行是否存在,执行用户激活工作,然后从表中删除该行。 If the user then goes to the very same URL again later, the row won't be there and the user won't be (re-)activated. 如果用户随后再转到相同的URL,则该行将不存在,并且不会(重新)激活用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM