C # QQ Mailbox registration, and a few seconds

Source: Internet
Author: User

One

This is what the front desk needs.

<asp:textbox id= "Textemail" runat= "Server" cssclass= "noneinput" placeholder= "Please enter your email account" onblur= "email ()" ></ Asp:textbox>
<asp:button id= "Button2" runat= "server" text= "Get Verification Code" cssclass= "Zcnext am-fr am-btn-default" onclick= "button2_click "/>

<asp:hiddenfield id= "Hftimer" runat= "Server"/>//this is the storage time
<asp:hiddenfield id= "Time" runat= "Server"/>//this is used to determine the verification code expires

This is the JS code section

<script>
var interval = 1000;
function Showcountdown () {
var date = $ ("#<%=hftimer.clientid%>"). Val ();//This is the value of the hidden control that gets the previous hold time
var now = new Date ();


var endDate = new Date (date);
if (now < endDate) {
var lefttime = Enddate.gettime ()-now.gettime ();
var leftsecond = parseint (lefttime/1000);
Ar day1=parseint (leftsecond/(24*60*60*6));
var day1 = Math.floor (Leftsecond/(60 * 60 * 24));
var hour = Math.floor ((leftsecond-day1 * 24 * 60 * 60)/3600);
var minute = Math.floor ((leftsecond-day1 * * * 60-hour * 3600)/60);
var second = Math.floor (leftsecond-day1 * * * 60-hour * 3600-minute * 60);
document.getElementById ("Timerh"). InnerHTML = Day1 * + hour;
document.getElementById ("Timerm"). InnerHTML = minute;
document.getElementById ("Miao"). InnerHTML = second;
} else {
document.getElementById ("Miao"). InnerHTML = "";//when time expires into empty
var ts = $ ("#<%=time". ClientID%> "). Val (" Failure ");//This is the value of the hidden control that is used to determine the expiration of the Verification code

}



}
Window.setinterval (function () {Showcountdown ();}, Interval);
</script>

Here's the backstage code.

protected void button2_click (object sender, EventArgs e)
{
MailMessage msg = new MailMessage (); Instantiation of an email class

string email = Textemail.Text.Trim ();
if (email!= "")
{
Msg. To.add (email);
Msg. Cc.  ADD ("[email protected]"); CC Person Address
Msg. from = new MailAddress ("[Email protected]", "Cui Qiang"); Sender Address
Msg. Subject = "Verification Code"; Message header
Msg. subjectencoding = Encoding.UTF8; Character format


Msg. Body =suiji (); Message content here is a method to return a four-digit verification code
Session["yan"] = Msg.  Body; Save the contents of the message to the session
Msg. bodyencoding = Encoding.UTF8; Set the encoding format for message content

SmtpClient client = new SmtpClient (); SMTP protocol for transporting simple messages
Client. Host = "smtp.qq.com"; The IP address of QQ
Client. Port = 587; Port of the transaction
Client. Enablessl = true; Encrypted links
Client.  Credentials = new NetworkCredential ("[Email protected]", "RRCNTQLLBHAHJGCD"); Used to verify the identity credentials of the sender
Client. Send (msg); Sends a message to an SMTP server, passing

DateTime timed = System.DateTime.Now;
DateTime times = timed. AddMinutes (1);//Add a minute to the current time
Hftimer.value = times. ToString ("Yyyy/mm/dd HH:mm:ss");//Assigning a value to the foreground's hidden control
Time. Value = "";//assign NULL to the control used to verify the expiration of the Verification code
}

}

C # QQ Mailbox registration, and a few seconds

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.