Introduction
In this tutorial, we will learn how to create an ASP.NET newsletter application which will allow us to send emails to subscribers of our newsletter. First, we will display a subscription form to the user. Upon entering the email address, we will verify it by sending a validation email. Upon clicking the link in that validation email, the user will be able to validate/confirm his email address and complete the registration process. We will then use a simple online ASP.NET administration interface to create and send newsletters.
Background
At Stardeveloper.com, I had always wanted to have a newsletter to inform the users of new articles and updates. But due to time constraints, I was never able to actually do it. This time though I thought I will develop something really useful which will not only add value to my website but will be equally useful to my readers. I should also acknowledge that I am and will be using this newsletter application at Stardeveloper.com. This is indeed a very solid application.
Copyright & Licensing
I am making the code (v1.0) free for study and use for all non-for-profit organizations and private use. For commercial users and those looking to help support the development of opensource software, I request that they buy a valid license for this Newsletter Application.
Requirements
This newsletter application will make use of ASP.NET 2.0 and SQL Server 2005 Express Edition. It is assumed that you have working installations of Microsoft Visual Web Developer Express Edition, SQL Server 2005 Express Edition and SQL Server Management Studio Express on your computer. We will use the built-in ASP.NET server in Visual Web Developer Express Edition to launch our ASP.NET application. If any of the programs are missing, then please proceed to www.microsoft.com to download and install the necessary applications.
Note: If you have either installed IIS on your computer or have access to it online, then you don't really need Visual Web Developer Express. Likewise, SQL Server Management Studio Express is only required so that you can run the SQL statements that I will provide later to create tables and stored procedures in your SQL Server 2005 database. If you can run the SQL statements by some other method, then SQL Server Management Studio Express is not required.
Application Preview
Please have a look at images below to get a feel for this application. The details of how everything is developed and constructed from plain ground will be discussed later on.
- Subscription Form: A form that allows users to enter their email addresses and subscribe to our newsletter.

- Subscription Form: If the user attempts to enter an invalid email address or if he tries to submit the form without entering any email address, a red asterisk will be shown next to the input field.

- Subscription Form: When the user enters a valid email address, his email address will be stored in the database and he will be sent a validation email. He will be prompted to check his email and complete the registration by clicking the link in that email.

- Administration Interface: A simple online administration interface allows the admin to create and send emails to subscribers.

First Step: Creating the Database Backend
The database backend for our newsletter application will consist of 5 tables and 24 stored procedures. The tables diagram is shown below:
As the diagram shows, there are 3 important entities in this application:
- Subscribers: Represented by the [Subscribers] table, they are actual users who subscribed to our newsletter. It includes all subscribers, validated or questionable (who have not responded to validation emails).
Note: We only ask and store a subscriber's email address. We do not ask for other things like 'name' or 'address'.
![[Subscribers]](/images/articles/2008100201_tables_diagram_subscribers_table_selected.png)
- Prepared Emails: They are emails that we create as part of our newsletter to be sent later to the subscribers. We store them in [PreparedEmails] table.
![[PreparedEmails]](/images/articles/2008100201_tables_diagram_preparedemails_table_selected.png)
- Jobs: When we will want to send (prepared) emails to our subscribers, we will create jobs in the [Jobs] table to do the job for us. They will be executed by separate threads which will run in the background. Thus, you can start a job and close your browser and go and do something else. You will not be required to sit in front of your computer. The jobs will run on the ASP.NET server in the background. Different jobs can be run simultaneously. A job is represented by the [Jobs] table. [LoggedMessages] table will keep the log of the messages sent by the thread(s) running the job(s) of the status of the job, like how many emails have been sent and so on. [JobEmails] table contains the list of subscribers to whom this prepared email should be sent as part of this job.
![[Jobs], [JobEmails], and [LoggedMessages] tables](/images/articles/2008100201_tables_diagram_jobs_and_related_tables_selected.png)
Now that we understand the logical entities that make-up this application and its database backend, we should now move on to create the tables in the SQL Server 2005 database.