·建站首页 ·钻石 ·繁體
您的位置: 中国建站之家 -> 网站开发设计 -> ASP教程 -> 使用ASPMail组件发送数字卡片

使用ASPMail组件发送数字卡片

作者:未知  来源:转载  发布时间:2005-7-28 20:40:54  发布人:acx

Sending Digital PostCards with ASP and the free component ASPEmail from Persits software.
By Joao Vieira

What is a Digital Postcard?
A digital postcard is a image a net surfer picks out, along with an accompanying personal message. The net surfer "sends" the postcard by supplying a friend's email address. A link is then emailed to the address supplied. The link takes the receiver of the digital postcard to the site which displays the image and contains the personal message.



First you must create a database to house the information for the postcards. (I use a DataBase to put the PostCards information so that when a person gets the mail with the post card only have to click on the link and the page apears, goin to DB to get the Data. So here it is the structure of my DataBase (you can make your own, with more information if you intend to.


Postal
ID_POSTAL Autonumber
passw integer
postal Text
nameto Text
namefrom Text
emailfrom Text
emailto Text
Message Text
Data Text

For the digital postcard system to work, you will need a number of images for the postcards. In my example I have six unique postcards, and 12 images for the postcards: a thumbnail and normal size image for each postcard. I also use images for buttons, the main ones being View, Send, and Repeat.

Concerning the code, I want to warn you that I am not going to be going deep into the HTML aspect; I will concentrate on the ASP. If you have any questions about this article, please contact me.

You will have to make an HTML form. I used the POST method, because I don't like to see all ofthe information submitted in the address link box. (Related Article! Passing Data Between ASP Pages)

FILE: makin.html
This file contains the form where we get all of the information from the user. This information will be used to make the digital postcard.

<form  
     name="postalsent"  
     method="post"  
     action="view.asp?fromn=seeit"  
     target="_self"
>

.....
    <td width="24" valign="bottom">
       <font face="Arial">
         <input type="radio" value="postal1" name ="R1">
       </font>
    </td>

    <td width="140">
       <font face="Arial">
      <IMG border=2 height=86 src="http://www.7880.com/Info/images/postal1.gif" width=134>
       </font>
    </td>

    <td width="12" valign="bottom">
       <font face=3D"Arial">                 
          <input type="radio" value="postal2" name ="R1">
       </font>
    </td>

    <td width="151">
       <font face="Arial">
          <IMG border=2 height=87 src="http://www.7880.com/Info/images/postal2.gif" width=134>
       </font>
    </td>
  </tr>

  <tr>
    <td width="24" valign="bottom">
        <font face="Arial">
           <input type="radio" value="postal3" name="R1">
        </font>
    </td>

    <td width="140">
        <font face="Arial">
           <IMG border=2 height=88 src="http://www.7880.com/Info/images/postal3.gif" width=135>
        </font>
    </td>

    <td width="12" valign="bottom">
        <font face="Arial">
           <input type="radio" value="postal4" name="R1">
......




  <INPUT name="nameto" size=18 style="LEFT: 1px; TOP: 2px">
  <input name="emailto" size="18">
  <input name="namefrom" size="18">
  <input name="emailfrom" size="18">
  <TEXTAREA cols=18 name=message rows=2></TEXTAREA>
  <input type="image" name="bseeit" src="http://www.7880.com/Info/images/seesentbotton.gif"
      border=0 height=51 width=110>
   

   <td width="32%">
     <a href="makin.htm">
        <img border=0 height=53 src="http://www.7880.com/Info/images/resetbotton.gif" width=41>
     </a>
   </td>

......

As you see in this example I use an image for Submit Button, and another image for reset button, at the reset button I made a reload of the page (refresh) that really cleans all the fields.

At action="view.asp?fromn=seeit" I use fromn to know if view.asp is being accessed from the creation phase or from the person that wants to view the digital postcard that was sent to them. I chose to set fromn to Seeit if we are still in the creation phase, and out if we are wanting to view the postcard.

In the file makin.html all we want to do is to send the information collected in the above FORM. The fields that i'm using are the ones named above: R1, nameto, mailto, namefrom, emailfrom.

FILE: view.asp
This the the important part, here we will see if there is a person previewing the card before sending it, or a person viewing card already sent. We will take all the information sent by the POST form of the previous file.

<%
Dim fromn
Dim ident
Dim psw

' erring tells us if the card already
' exists.  By default, we assum it does.
Dim erring  

' I normaly use 0 and 1 for boolean,  
' cause it is quicker
erring = 0  


' Receiving the information    
' from the link that led to this file;
' this one tell us
' what kind of access we're doing
fromn = Request.QueryString("fromn")
  
' here we take the ID from the post card,  
' for us to know wich card we want to see.
' All this information will be compared with  
' the one in the database.
ident = Request.QueryString("ident")  


' This is the password
' We do not want a person that knows there exists a  
' postcard with ID 13 tries to see one with ID 12.
' We will generate a random number for the password
psw = Request.QueryString("psw")  

if fromn = "seeit" then  
     ' If we just want to see the preview
     ' I have created sessions to keep the information,
     ' so that I can view the data at any step
     session("postal") = Request.for

[1] [2] [3]  下一页

将本文收藏到QQ书签与更多好友分享