- The registration page is no longer written, now paste the code that sent the message
Public ActionResult sendemial () {int customerid= 1; String validatacode = System.Guid.NewGuid (). ToString (); try {System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress ([email protected], "Wode"); Fill in the email address, and display name System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress ([email protected], "Nide"); Fill in the recipient address and name of the message//set the Send address, and receive address, the receive address can be multiple System.Net.Mail.MailMessage mail = new System.Net. Mail.mailmessage (); Mail. from = from; Mail. To.add (to); Mail. Subject = "Subject content"; System.Text.StringBuilder strbody = new System.Text.StringBuilder (); Strbody.append ("Click the link below to activate the account, 48 hours, or re-register the account, the link can only be used once, please activate as soon as possible!" </br> "); Strbody.append ("<a href= ' http://localhost:3210/Order/ActivePage?customerID=" + customerid+ "&validatacode =" + Validatacode + "' > click here </a></br>"); Mail. Body = Strbody.tostring (); Mail. isbodyhtml = true;//Settings display HTMLS//Set up Send mail service address System.Net.Mail.SmtpClient client = new SYSTEM.N Et. Mail.smtpclient (); Client. Host = "smtp.163.com"; Fill in the User name and password information associated with the server address client. Credentials = new System.Net.NetworkCredential ("[Email pRotected] "," xxxxxx "); Send mail client. Send (mail); } catch {} return new Emptyresult (); }
Description
- Fill in the User name and password information associated with the server address client. Credentials = new System.Net.NetworkCredential ("[email protected]", "xxxxxx");
This needs to fill out the sender's mailbox name and password
- The contents of the message sent here will not show the linked address information, only in the way of hyperlinks, the effect:
3. Verification code is valid in two cases: 1. Verify that the link is activated within the specified time period, 2. Verify that the code is the same as the one saved in the database
- Page requires three pages: 1. Registration page; 2. Activate page; 3. Failed page.
- Add an Active Status field to the database table-1 or 1 (-1 is inactive, 1 inactive), add a CAPTCHA field Validatecode, and finally add a registration Time field registereddate
- program, the registration page to add registration information, randomly generated registration code (GUID) added to the database, the user ID and verification code as a parameter sent to the mailbox
- Because ASP. NET MVC does not need to write code to get the parameters in the URL, the parameters in the action as long as the corresponding in the URL, the action will help us to automatically get the parameter information in the URL
- Query the database with parameter information in action to determine if registration information can be activated
Implementation of the Mailbox activation feature in ASP. NET MVC Registration