摘要:利用 Asp.net 寄發信件
try
{
System.Net.Mail.MailMessage newMail = new System.Net.Mail.MailMessage();
//SMTP伺服器設定
System.Net.Mail.SmtpClient smtpMail = new System.Net.Mail.SmtpClient(smtp, 25);
//寄件內容
{
newMail.From = new System.Net.Mail.MailAddress(SendUser, "from");
//寄件者
newMail.Body = body;
//內文
newMail.Subject = title;
//主旨
//新增收件者
newMail.To.Add(new System.Net.Mail.MailAddress(ReciveUser, "to"));
//密件副本。
//newMail.Bcc.Add(new System.Net.Mail.MailAddress(" yourEmail ", "bcc"));
//是否為HTML格式
newMail.IsBodyHtml = true;
//優先權
newMail.Priority = System.Net.Mail.MailPriority.Normal;
}
//寄出信件
smtpMail.Send(newMail);
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "<script> alert('信件成功寄出') </script>");
}
catch (Exception ex)
{
throw ex;
}