You have to put that code inside an event handler like Page_Load, or a
button click, in this way:
Sub btn_Click(sender as Object, e as System.EventArgs)
If request.form("EmailAddress") <> ""
Dim mail As New MailMessage
mail.From = "youraddress@..."
mail.To = request.form("EmailAddress")
mail.Subject = "Message sent using ASP.NET and CDONTS"
mail.Body = "HTML Message sent from ASPFree.com using ASP.NET
and Cdonts<br><a href='http://aspfree.com/aspnet/email.aspx'>Wonder how
this is done?</a><br><br><a
href='http://aspfree.com/aspnet/setupcdonts.aspx'>Wonder How to setup
CDONTS?</a>"
mail.BodyFormat = MailFormat.Html
SmtpMail.SmtpServer = "LocalServerName"
SmtpMail.Send(mail)
End If
End Sub
Then when you define the button (<input>) you should use
OnServerClick="btn_Click" or if you use a Button webcontrol
(<asp:Button>) define the OnClick event handler