After successful registration, the user can send the user name and password to their registered email address.

Source: Internet
Author: User
Tags mailmessage smtpclient

/// <Summary>
/// Send the user account and password at registration
/// </Summary>
/// <Param name = "receiver"> User Registration email </param>
/// <Param name = "username"> User name </param>
/// <Param name = "password"> plaintext of the User password </param>
Public bool Register (string er, string username, string password)
{
System. Net. Mail. SmtpClient client;
Client = new System. Net. Mail. SmtpClient ("smtp.126.com ");
Client. Timeout = 60000;
Client. usedefacrecredentials = false;
Client. Credentials = new System. Net. NetworkCredential ("mailbox number", "Mailbox password ");
Client. DeliveryMethod = System. Net. Mail. SmtpDeliveryMethod. Network;
System. Net. Mail. MailMessage message = new System. Net. Mail. MailMessage ();
Message. SubjectEncoding = System. Text. Encoding. UTF8;
Message. BodyEncoding = System. Text. Encoding. UTF8;
Message. From = new System. Net. Mail. MailAddress ("mailbox number", "display name", System. Text. Encoding. UTF8 );
Message. To. Add (new System. Net. Mail. MailAddress (receiver, username, System. Text. Encoding. UTF8 ));
Message. IsBodyHtml = false; // whether it is html-encoded
Message. Subject = "User Registration Information ";
Message. Body = username + ": Hello! /R/n your registered username is: "+ username +"; password is: "+ password + ". /R/n ";
Try
{
Client. Send (message );
Response. Write ("sent successfully! ");
Return true;
}
Catch
{
Return false;
}
}

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.