We support Microsoft .NET Framework 2.0 & 1.1, all versions of Access, SQL 2000, SQL 7.0, SQL 2005 Express, SOAP, FrontPage 2002, 2003, Visual Studio 2005, Index Server, XML, UDDI, & Mobile device support. We also offer great third party tools like SmarterMail, Merak Mail, SmarterStats, PHP, Perl, MySql, DeepMetrix Livestats XSP 8.0.   We support Microsoft .NET Framework 2.0 & 1.1, all versions of Access, SQL 2000, SQL 7.0, SQL 2005 Express, SOAP, FrontPage 2002, 2003, Visual Studio 2005, Index Server, XML, UDDI, & Mobile device support. We also offer great third party tools like SmarterMail, Merak Mail, SmarterStats, PHP, Perl, MySql, DeepMetrix Livestats XSP 8.0.
 Thursday, May 17, 2007

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. Change only mail server and default email within the script.   Code: ASP.NET v2.0 & VB

<%@ 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 = "Whoever@DomainName.com"
  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.Domainname.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>

Dev
5/17/2007 5:16:08 PM (Pacific Daylight Time, UTC-07:00)  #    Disclaimer  |   | 
Related Posts:
EGroupware
Microsoft and Iron Ruby
SQL injection
Synchronize Mysql data with php
IE 8 passes ACID2 test
SQL Speed Tip