Imports System.Net.Mail Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load txtName.Focus() If Not Page.IsPostBack Then validar() End Sub Protected Sub btnEnviar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnEnviar.Click If txtValidator.Text <> hidden.Value Then status.Text = "<span style='color:red'><b>Validation is incorrect.</b></span>" Exit Sub End If Dim s As String = "<div style='font-family:Arial; font-size:12px;'>" s += "Message sent: " & Now s += "<br>" s += "<br><b>Name:</b><br /> " & txtName.Text s += "<br><b>Phone:</b><br /> " & txtPhone.Text s += "<br><b>E-mail:</b><br /> " & txtEmail.Text s += "<br><b>TimeScale:</b><br /> " & ddlSubject1.SelectedValue s += "<br><b>Budget:</b><br /> " & ddlSubject0.SelectedValue s += "<br><b>Message:</b><br /> " & txtMessage.Text s += "</div>" Dim oEmail As New MailMessage oEmail.IsBodyHtml = True oEmail.Body = s oEmail.Subject = "New Website Email " + ddlSubject.SelectedValue oEmail.From = New MailAddress("******") oEmail.To.Add("**********") Dim envia As New SmtpClient("localhost") Try envia.Send(oEmail) status.Text = "<span style='color:green'><b>Congratulations! E-mail has been sent.</b></a>" txtEmail.Text = "" txtMessage.Text = "" txtName.Text = "" txtPhone.Text = "" ddlSubject1.SelectedValue = "0" ddlSubject0.SelectedValue = "0" ddlSubject.SelectedValue = "0" txtValidator.Text = "" Catch ex As Exception status.Text = "<span style='color:red'><b>Error. E-mail didn't sent.</b></a>" Exit Sub End Try End Sub End Class