One feature that has increasingly become a must have on a SME business website is a form that visitors to your site can use to contact you via email. Thankfully this is quite easy to set up with a little knowledge of HTML, ASP and an email component like Persits ASP Email.

In the example below we create a simple form with fields for the visitor to enter their name, email address and message, with a button to submit the form.

Example 1: form.asp

<html>
<body>
<form method="post" action="contact.asp">
<label for="email">Email Address:</label>
<input type="text" name="email" id="email"><br>
<label for="name">Name:</label>
<input type="text" name="name" id="name"><br>
<label for="message">Message:</label><br>
<textarea name="message" id="message"></textarea><br>
<input type="submit" name="send" value="send message">
</form>
</body>
</html>

Next, we create contact.asp which the form will be submitted to. In the example below, the strSubject and strEmail values can be customised, the former being the subject of the email and the latter the email address that the submitted form will be emailed to. The next section will process the email and the html will check for errors and output a message which will either announce the mail was sent successfully or report an error message (for debugging purposes).

Example 2: Contact.asp

<% 'Define settings
strSubject = "Form submitted" 'email subject
strEmail = "[email protected]" 'email address

'Confirm form has been submitted
If Request("send") <> "" Then
Set Mail = Server.CreateObject("Persits.MailSender")

Mail.Host = "localhost"
Mail.From = Request("email") ' From address
Mail.FromName = Request("name") ' optional
Mail.AddAddress StrEmail ' to address
Mail.Subject = strSubject ' message subject
Mail.Body = Request("message") ' message body
strErr = ""
bSuccess = False
On Error Resume Next ' catch errors
Mail.Send ' send message
If Err <> 0 Then ' error occurred
strErr = Err.Description
else
bSuccess = True
End If
End If
%>


<html>
<head>
<title>Form Submiited</title>
</head>
<body>
<% If strErr <> "" Then %>
Error occurred: <% = strErr %>
<% End If %>
<% If bSuccess Then %>
Your message was sent successfully.
<% End If %>
</body>
</html>

The above example is just something to get you started, the component has more features available for advanced uses, please refer to the official documentation (http://www.aspemail.com/manual_02.html) for more information.