An ASP Tutorial to create your own News Letter

An ASP Tutorial to create your own News Letter
by Faisal Khan.

News letters are part and parcel of every good site on the web today. When a web site visitor enters it's email address into the news letter input box, it is saved into the database. As more and more visitors enter their email addresses, the mailing list grows. Then when ever the you want, you can send emails in one go to all the users of your mailing list. News letters are a great way to inform web site users of latest news and information about your web site.

High-end commercial email component :

i. AspEmail : Most feature-rich mailing component. Supports message queueing, embedded images, secure mail, authentication. Read more.

In this article I will guide you through the steps of creating a simple but effective news letter. We will divide our work into three steps :

  • Step 1 : Create a simple HTML Form where users can insert their email addresses and an ASP page which will receive the Form email address from the HTML page and insert it into the database.
  • Step 2 : Create a simple Access database to store user's email addresses.
  • Step 3 : A simple admin ASP page from where you can send email messages to all the users whose email addresses are present in the database.
  • Step 4 : An ASP page from where the users can delete their email addresses from the database if they later choose to.

Alright then lets now move to the creation of our News Letter messaging system.

Simple HTML Form
Create a new HTML page and name it 'mail.htm' and then add the following code in the 'body' section of that page :-

News Letter :

Above HTML code will produce a simple input box where users can enter their email addresses. After entering their email address and pressing the 'submit' button, the users email address will be ported to our 'mail_ac.asp' page where the email address will be inserted into the database. You can edit it to suite the design of your site.

Form Action Page
Open notepad or any text editor for that matter and add the following lines of code into it and then save it as 'mail_ac.asp' in the same directory where you have put the above 'mail.htm' page.

 
      

This 'mail_ac.asp' page will first check to see if the user has just pressed the 'submit' button and has not entered the email address, if it is so then the user will be redirected back to the 'mail.htm' page. If the user entered it's email address then first check database to see if it's already present or not. If email address is not found in the database then add it otherwise tell the user that the email address is already present and exit.

Simple Access Database
Now we will create a simple Access database with just one table 'users' containing two fields, 'id' and 'email' respectively. If you are not comfortable with creating simplest of Access databases then you might want to read the database tutorial I have compiled for you. Note that at the end of this article you can download the sample database and code mentioned in this article. Open Microsoft Access and create a database 'mail.mdb' and save it in the same directory where you are creating other HTML and ASP files for this tutorial. In 'design view' of Microsoft Access our 'users' table will look like :

Users - Table
Users - Table

Ok, we've completed first two steps. Now we'll move on to the next page where we will create 'admin' page and an email deletion page from where users can delete their email addresses from your database.

We have created an HTML Form to receive user's email address, an ASP action page to insert that email address into the database and an Access database to receive and store those email addresses. We will now create an admin page from where we can send emails to all the users on our mailing list at once and an email deletion page from where users can delete their email addresses if they later want to.

HTML Admin Page
Create a new HTML page and paste following lines in it's 'body' section :

 
      

Save it as 'admin.htm'. All it will do is to provide you with an online Form from where you can send messages to all the users of your mailing list.

ASP Admin Action Page
This ASP page will receive the contents of above 'admin.htm' page and will send the actual emails to all the users. Copy and paste the following lines of code into a new page and then save it as 'admin_ac.asp' in the same directory where you have been saving the other pages :


 
  

Done sending emails to all the users in our mailing list. Lets now create a 'del.asp' page whose link we have already added in our messages. Users will be able to delete their emails from out database if they want it by clicking the link we provided to them in their emails.

Note if you are getting errors when testing this script on your own computer, then search in the 'windows/sytem/' diretory ( win95/98 users ) or 'winnt/system32' directory ( winnt/2000 users ) if 'cdonts.dll' is present there or not. If it's not then get it from the Windows CD or search it on www.microsoft.com. You should change the URL provided in above code for the email deletion page to the URL where that 'del.asp' page will actually reside.

ASP Email Deletion Page
Create a new page and add the following lines of code into and then save it as 'del.asp' in the same folder where you have kept other pages :

 
  

We are now done with creating our ASP based news letter for our site. I have delibrately kept things simple so that beginners can also understand whats going on. You can add your own features to it as you want.

转载于:https://www.cnblogs.com/settinghead/archive/2004/10/18/53887.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值