Return to Snippet

Revision: 38495
at January 4, 2011 07:06 by rts_dev


Initial Code
Imports System.Net.Mail
Imports System.Net.Configuration
Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub btnSumbit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSumbit.Click
        Dim client As New SmtpClient("RS-E133-V.bckcom.com")
        Dim mmsg As New MailMessage("[email protected]", "[email protected]")
        mmsg.IsBodyHtml = True
        mmsg.Body &= "<html>"
        mmsg.Body &= "<body>"
        mmsg.Body &= "<style type&='text/css'>body{font:arial, verdana; font-size:11pt;}b{font-size:10pt; color:blue;}</style>"
        mmsg.Body &= "<b>Time Submited: </b> " + DateTime.Now
        mmsg.Body &= "<br />"
        mmsg.Body &= "Sentby: " + tbName.Text
        mmsg.Body &= "<br />"
        mmsg.Body &= "<hr />"
        mmsg.Body &= "<b>First Name: </b> " + tbName.Text
        mmsg.Body &= "<br />"
        mmsg.Body &= "<b>Email: </b> " + tbEmail.Text
        mmsg.Body &= "<br />"
        mmsg.Body &= "<b>Message: </b> " + tbMessage.Value
        mmsg.Body &= "<br />"
        mmsg.Subject &= "Subject" 'Type in Subject Here
        'Now, to send the message, use the Send method of the SmtpMail class
        If IsValid Then
            client.Send(mmsg)
            Response.Redirect("~/Thankyou.aspx") 'Where the form should redirect to, don't forget to create this page
        End If
    End Sub
End Class

Initial URL

                                

Initial Description
Make sure to change the partial class name. It's based on the page name. Also, don't forget to create a ThankYou.aspx page!

Initial Title
VB.NET  for a Basic ASP.net Contact Form (Includes Full Name, Email, and Message Fields)

Initial Tags

                                

Initial Language
VB.NET