Asp. Net how to send mail, asp.net send mail
/// <Summary> /// send an email to the user /// </summary> /// <param name = "email"> User's email address </param> // /<param name = "activecode"> activation code </param> public void sendEmail (string email, string activecode, int userId) {// The first thing to declare is: before using this method, make sure that the SMTP service of the sender's mailbox is enabled !!!! Otherwise, an error is reported! // Email is the target email address MailMessage mailMsg = new MailMessage (); // two classes. Do not mix them. Introduce System. net Assembly mailMsg. from = new MailAddress ("Email address", "sender name (can be blank)"); // source Email address, sender Email mailMsg. to. add (new MailAddress (email); // target email address. There can be multiple recipients mailMsg. Subject = "sample, hello! "; // The Mail title string url =" <a href =' http://localhost:8899/ashx/Active.ashx?userId= "+ UserId +" & code = "+ activecode +" '> Click Activate </a> "; mailMsg. body = url; // the content of the sent Email mailMsg. isBodyHtml = true; // Let the mailbox parse the content SmtpClient client = new SmtpClient ("smtp.sina.cn"); // define the SMTP server smtp.163.com and smtp.qq.com client used by the sender. credentials = new NetworkCredential ("name", "pwd"); // specify the user name and password of the sender's mailbox client. send (mailMsg); // Send the mail content to the SMTP server .}