asp.net
using System.web.Mail;
MailMessage msg = new MailMessage();
//發送方地址(如test@163.com)
msg.From = "zdyguilong@163.com";
//接收方地址(如test@163.com)
msg.To = "zdyguilong@163.com";
//本文內容類型
msg.BodyFormat = MailFormat.Html;
//本文內容編碼
msg.BodyEncoding = System.Text.Encoding.Default;
//主題
msg.Subject = "張大宇向您問好";
//內容
msg.Body = "<html><head><META content=zh-cn http-equiv=Content-Language><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><style type=text/css>A:link { FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #000000}A:visited {FONT-SIZE: 9pt; TEXT-DECORATION: none; color: #666666}A:hover {COLOR: #ff6600; FONT-SIZE: 9pt; TEXT-DECORATION: underline}BODY {FONT-SIZE: 9pt} --></style></head><body><font color=red>使用者名稱:" + UserName.Text.Trim() + "</font><br><font color=green>密碼:" + strUserPsw.ToString() + "</font><br><b>驗證地址:</b><a href='http://192.168.1.98/AllFiles/Member/CheckFromEmail.aspx?UserName=" + UserName.Text.Trim() + "'target=_blank>http://192.168.1.98/AllFiles/Member/CheckFromEmail.aspx?UserName=" + UserName.Text.Trim() + "</a>。如果您不能點選連結進行跳轉,請把這個地址粘貼到瀏覽器的地址欄直接存取。<br><font color=red>此郵件不必回複,謝謝。</font></body></html>";
//設定為需要使用者驗證
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//設定驗證使用者名稱
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "zdyguilong");
//設定驗證密碼
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456");
//郵件伺服器地址(如smtp.163.com)
SmtpMail.SmtpServer = "smtp.163.com";
//發送
SmtpMail.Send(msg);
//Response.Write("<script language='javascript'>alert('註冊成功');window.location='../default.aspx'</script>");