Login | Register  

A Simple Contact Form

by Scud   Tuesday, September 26, 2006 Rating:
 Vote this news:


This is a very basic contact form which can be used for any kind of website. Web form contains name, email, subject and message inputs. When visitor ckicks send button, script send all informatiom from contact form.  Change only mail server and default email within the script.


<%@ Page Language="VB" Debug="true" %>
<% @Import Namespace="System.Web.Mail" %>
<script language="vb" runat="server">

Sub Send2Mail (sender as Object, e as EventArgs)

Dim objMail as New MailMessage()

  objMail.To = "TAREGET_EMAIL@ADRESS"
  objMail.From = strEmail.Text

  objMail.BodyFormat = MailFormat.Text
  objMail.Priority = MailPriority.Normal
  objMail.Subject = strSubject.Text

  objMail.Body = "Name : " + strName.Text + vbNewLine + "Email : " + strEmail.text + vbnewLine + "Message : " + strYourMsg.text
  
  SmtpMail.SmtpServer = "mail.YOUR_SMTP_SERVER.com"
  SmtpMail.Send(objMail)


  strMessage.Visible = true

End Sub

</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>How to send email</title>
</head>
<body>

  <asp:panel id="strMessage" runat="server" Visible="False">
      Thanks for your kind message ...  </asp:panel>

    <form runat="server">
      <b>First Name:</b> <br/>
      <asp:textbox id="strName" runat="server" />
      <br><br>

      <b>Email Address:</b><br/>
      <asp:textbox id="strEmail" runat="server" />
       <br><br>

      <b>Subject:</b><br/>
      <asp:textbox id="strSubject" runat="server" />
       <br><br>

       <b>Your Message</b><br/>
      <asp:textbox id="strYourMsg" runat="server" Columns="45" Rows="10" TextMode="MultiLine" />
        <br />
      <asp:button runat="server" id="func" Text="Send Message"
                  OnClick="Send2Mail" />
    </form>
</body>
</html>







Dotnetindex.com is listed with 411asp.net
Dotnetindex.com is listed with aspin.com
Dotnetindex.com is listed with jspin.com
PHP, ASP, .NET, JSP Resources, Reviews







page counter
Copyright © 2007 Powered by GNews Publisher Positive. All rights reserved. Contact Us - Load Time: 0.05 second(s)