Monday, March 3, 2008

ASP.Net - Send simple e-mail

Send simple e-mail

The code to send a simple e-mail is pretty simple and very small. There isn't much to explain either.

Dim msg As New Net.Mail.MailMessage(
_txtFrom.Text, _txtTo.Text,
_txtSubject.Text, _txtMessage.Text)

Dim mySmtp As New Net.Mail.SmtpClient("localhost")
Try
mySmtp.Send(msg)
lblResult.Text = "Mail Sent"
Catch ex As Exception
lblResult.Text = ex.Message
End Try

No comments: