ASP.NET寄發E-Mail

摘要:ASP.NET寄發E-Mail


aspx.cs

1 using System.Net.Mail;

……

1     protected void btnSend_Click(object sender, EventArgs e)
2     {
3         MailMessage message = new MailMessage(tbxSender.Text, tbxGeter.Text, tbxSubject.Text, tbxMessage.Text);
4         message.IsBodyHtml = true;
5
6         SmtpClient SMTP = new SmtpClient("localhost");
7         SMTP.Send(message);
8     }

要安裝 SMTP Service 才可以在本機(localhost)發信!