website analytics, SEO, tutorials, articles Help me Build a .Com - website analytics, SEO Help me Build a .Com - website analytics, SEO website analytics, SEO, tutorials, articles
Back Home.Abount Us.Need Help?Contact Us.
about us - Help me Build a .Com - website analytics, SEO
members area - Help me Build a .Com - website analytics, SEO
services - Help me Build a .Com - website analytics, SEO
frequently asked questions - Help me Build a .Com - website analytics, SEO
Links to Useful Resources - Help me Build a .Com - website analytics, SEO
Contact Us - Help me Build a .Com - website analytics, SEO

Help me Build a .Com - website analytics, SEO

Would you Like our Newsletter?

Name
Email Address
 


 
 




Tutorial

 


Email Capture and Response Tutorial

 

In this tutorial we will create an opt in Email capture function for your website - Which will store the opt in address in a database before sending a confirmation email via SMTP.

We will use an MS Access database as the means of storing data although in truth this could be done with a flat file if you don’t have access to MS Access.

But before we begin designing or coding it’s probably best to address a point that has become tiresome.

The question often comes into conversation as ‘Why should I bother collecting email addresses when I can buy them by the million on the web?’
This is a simple question that illustrates that the person asking it either:
A.is a spammer/con man
B.has very little experience of his own relating to web marketing

We collect and build our own email data because:

  1. These people are interested in the products that our site sells (or they would leave their email address)
  2. When you collect someone’s email address it’s also possible to collect other information at the same time. The important pieces of information are the IP address that they are logged on at and the current date/time.
  3. When you collect your own email addresses it’s possible to act on the email address immediately (for example ‘thanks for subscribing’)
  4. You know that there aren’t thousands of other people using this address (unless they’ve given it out to thousands of people – or one or two spammers)

So there are definite advantages to capturing email addresses on your own. The best argument is of course that if you’re capturing email addresses from visitors to your own site then you are in fact not having to pay for them but are instead getting extra value for money from current visitors.

Just for the record – DO NOT buy email lists of the web, you are probably buying crap, you will more than likely be accused of sending out spam on your first mailing and you might well lose your site (your service provider will drop you like a bad habit if they start receiving allegations of spam).

The concept of ethical mailing will be dealt with in a special article of its own.
So down to business.

What will we achieve in this tutorial:

  1. We start by describing a database for your email data
  2. We will then add this to the ODBC data sources of either your machine or host
  3. We will then design a simple html form to insert onto a page
  4. We will then write an ASP page to process the forms data
  5. We will then populate the data base with the form data
  6. We will then send an email to the email address provided.

What do you need to complete this tutorial?

  1. Access to MS access
  2. Either the ability to create a data source on your machine or that of your service provider (it is possible to do this without a DSN but for the purpose of this tutorial I will be using a DSN – data source name)
  3. Either a service provider or Personal Web Server/IIS

If you have not got access to MS Access the database can be provided to you upon request.

1. Creating the Database

When creating the database we must decide what information we wish to hold on a user, this is after all only an opt in for a mailing list (newsletter for example).
The minimum information that we need to store is the users email address, the date/time when they opted in and the IP address from which they opted in.

This information, although basic, will allow you to defend yourself against allegations of spam.
It should be noted that different countries have different requirements with regard to ethical mailing, for example certain states within the US require you to capture a post code whilst others require a date of birth.

For the sake of simplicity we will store an email address, IP address and the date/time.

Our definition is as follows:

DB name: opinmailingdb
Table name: optin_addresses
File name(s): optin_emailaddress (text – 50)
optin_ipaddress (text – 50)
optin_date (Date – General)

We now have our database structure.

2. Adding the Database to ODBC

This task is dependant upon where you are working. If you are working on your own machine at home then it’s simply a matter of going to:

Start
Control Panel
Administrative tools
Datasources
Select system DSN from the tabs
Add new
Copy the name from below
Add your own description
Select your database file (Select)

 

 

You should now have a screen looking like the above.
If you’re using your service provider look for ODBC setup and just add the DSN using the name from the above graphic.

3. Creating a Simple HTML Form

Enter the following code into you HTML editor (or text editor)

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Email Capture Page</title>

</head>

<body>

<p>This is an Email Entry Page</p>

<form name="form1" method="post" action="email_process.asp">

<table width="245" border="0">

<tr>

<td width="96">Email Address </td>

<td width="88"><input name="txtUserEmail" type="text" id="txtUserEmail"></td>

</tr>

<tr>

<td>&nbsp;</td>

<td><input type="submit" name="Submit" value="Submit"></td>

</tr>

</table>

</form>

<p>&nbsp; </p>

</body>

</html>

This is a simple page with a comment and a form, nothing special.
Note that the form contains a text box called txtUserEmail.

4. Create an ASP Page to Process the Forms Data

The following code may be used directly, just remember it’s name should correspond to the name supplied in the ‘action=’ part of the form in the HTML page.

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Untitled Document</title>

</head>

<body>

<p>This form checks the Email Address and then adds it to the DB.</p>

<p>We recieved the following information:</p>

<% if request.Form("txtUserEmail") >"" and instr(request.Form("txtUserEmail"),"@") >0 then %>

<p>Email Address: <% response.Write(request.Form("txtUserEmail")) %></p>

<p>IP Address: <%Response.Write(Request.ServerVariables("REMOTE_ADDR"))%></p>

<p>Date/Time of Optin: <% response.Write(now()) %> </p>

else

response.write("No Data - Please Enter an Email Address to Subscribe")

end if %>

</body>

</html>

So with the above code we have a page to capture and email address and a page to process it.

Note:
The ‘processing’ on the page thus far checks only that data was supplied and that the supplied data contains an ‘@’ symbol. It is possible to do lots more checking on an email address to validate it (such as verifying that the domain name exists, check for a ‘.’, etc).

5. Add the Email Address to the Database.

Having got the code above we need to extend it to add a record to the database, add the following code to the ASP page after the <HTML> tag.

<%

str_dsn = "dsn=optin_data;"

set optin = Server.CreateObject("ADODB.Recordset")

optin.ActiveConnection = str_dsn

 

optin.Source = "SELECT * FROM optin_addresses"

optin.CursorType = 0

optin.CursorLocation = 2

optin.LockType = 3

optin.Open()

optin_numRows = 0

%>

This code is defining a link to the database table as an ADO DB connection. We don’t care about the results brought back in this query, we do care that the page has an open connection to the database.
Now add the following code before the ELSE statement:

<% ' now that we've echoed to screen your data lets add it to the DB.

optin.addnew

optin("optin_emailaddress") = Request.Form("txtUserEmail")

optin("optin_ipaddress") = Request.ServerVariables("REMOTE_ADDR")

optin("optin_date") = now()

optin.update

' we have now added the record to the DB.

This code will add the data to the database, note the use of the system function now and RMOTE_ADDR.

The NOW function will give you the time on the server, the REMOTE_ADDR value will give you the IP address of the machine connected to your server (this will be the dynamic IP address provided by the users service provider unless they have a static IP address for their internet connection).
We have now added data to the Database – Hoorah; you now have user data of your own.

6. Send an Automatic Confirmation Email

The world we live in is seldom fair, one of the things that isn’t fair is that a user can sign up for your newsletter and forget almost instantly – or alternatively can sign up and provide an incorrect email address.

In order to combat both of these problems it is best to send the supplied email address a confirmation email as soon as possible. This can be done automatically using the following code:

set objmail = Server.CreateObject("CDONTS.NewMail")

' set the properties

objmail.From = "webmaster@<yourdomain.com>"

objmail.To = Request.Form("txtUserEmail")

objmail.Subject = "Confirmation of Subsccription Required"

strbody = "Hi," & vbcrlf & "We have just been supplied this email address as an opt in address." &_

vbcrlf & "The address was supplied from the IP addres " & Response.Write(Request.ServerVariables("REMOTE_ADDR")) & vbcrlf &_

vbcrlf & "If this is correct please reply to this mail to confirm your opt in"

objmail.Body = strbody

' send the email

objmail.Send

set objmail = Nothing

Note:
<Yourdomain.com> - replace

Quite simply this piece of code, that should also be inserted before the else statement, create a CDONTS mail object and sends it via your servers SMTP server.

Why does the comment ask for a confirmation email?

It asks for a confirmation email so that you have what is called a double opt in email address, i.e. the user has requested information and then confirmed that they have requested information, this effectively makes you bullet proof for spam allegations (and is good practice).

When the user responds to your request for confirmation you should keep the email somewhere safe (just in case).
You should also consider altering the database to include a confirmed status flag that you can set manually when you have a reply, your subsequent mailings should then only use data that has the status set live.

You should now have a fully working email capture and response system, modify it, play with it, fit it into your own site. With the code supplied you could also write yourself an ASP based 'Contact us' function.

Copyright Info:
You may cut and paste this code and use it in your own pages freely, however if you use this code as part of an article of your own please give credit to this site.

You may not however rip off the entire tutorial and claim it is your own. If you want to use the entire tutorial, as is, then drop me an email – I’ll probably say yes, I just like to know where my material is being used (don’t forget – we’re consultants, could be embarrassing :-)


 
 

home | about us | e-mail Copyright HelpmeBuilda.Com 2005


when considering a consulting firm for SEO services or search engine optimisations it is important to examine articles, tutorials and web site analytics that they provide. One should also check to see if they perform SEO or web site design, website development for any other consulting ecommerce site. Website analytics is the study or analysis of web traffic to an ecommerce site based on certain key factors such as SEO (search engine optimisation) and online marketing
 


Free Keyword Checking
Word Tracker
If you want to check your keywords.

Autoresponder - Help me Build a .Com - website analytics, SEO
Free Autobot
If you want a free autoresponder


Resource for Newbies
If you're new to web development this is a good starting place.