#region 發送郵件 //填寫電子郵件地址,和顯示名稱 System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress("[email protected]", "wode"); //填寫郵件的收件人地址和名稱 System.Net.Mail.MailAddress to = new System.Net.Mail.MailAddress("[email protected]", "nide"); //設置好發送地址,和接收地址,接收地址可以是多個 System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(); mail.From = from; mail.To.Add(to); mail.Subject = "主題內容"; System.Text.StringBuilder strBody = new System.Text.StringBuilder(); strBody.Append("請通過單擊 <a href=\"" + callbackUrl + "\">這裏</a>來確認你的帳戶"); mail.Body = strBody.ToString(); mail.IsBodyHtml = true;//設置顯示htmls //設置好發送郵件服務地址 System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(); client.Host = "smtp.126.com"; //這裡發郵件用的是126,所以為"smtp.126.com" //填寫服務器地址相關的用戶名和密碼信息 client.Credentials = new System.Net.NetworkCredential("[email protected]", "這個需要到126郵箱裡開啟smtp,然後輸入設置的密碼"); //發送郵件 client.Send(mail); #endregion