|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
优点:简单易学、开发速度快、有很多年“历史”,能找到非常多别人做好的程序来用、配合activeX功能强大,很多php做不到的asp+activeX能做到,例如银行安全控件SendingDigitalPostCardswithASPandthefreecomponentASPEmailfromPersitssoftware.
ByJoaoVieira
WhatisaDigitalPostcard?
Adigitalpostcardisaimageanetsurferpicksout,alongwithanaccompanyingpersonalmessage.Thenetsurfer"sends"thepostcardbysupplyingafriendsemailaddress.Alinkisthenemailedtotheaddresssupplied.Thelinktakesthereceiverofthedigitalpostcardtothesitewhichdisplaystheimageandcontainsthepersonalmessage.
Firstyoumustcreateadatabasetohousetheinformationforthepostcards.(IuseaDataBasetoputthePostCardsinformationsothatwhenapersongetsthemailwiththepostcardonlyhavetoclickonthelinkandthepageapears,gointoDBtogettheData.SohereitisthestructureofmyDataBase(youcanmakeyourown,withmoreinformationifyouintendto.
Postal
ID_POSTALAutonumber
passwinteger
postalText
nametoText
namefromText
emailfromText
emailtoText
MessageText
DataText
Forthedigitalpostcardsystemtowork,youwillneedanumberofimagesforthepostcards.InmyexampleIhavesixuniquepostcards,and12imagesforthepostcards:athumbnailandnormalsizeimageforeachpostcard.Ialsouseimagesforbuttons,themainonesbeingView,Send,andRepeat.
Concerningthecode,IwanttowarnyouthatIamnotgoingtobegoingdeepintotheHTMLaspect;IwillconcentrateontheASP.Ifyouhaveanyquestionsaboutthisarticle,pleasecontactme.
YouwillhavetomakeanHTMLform.IusedthePOSTmethod,becauseIdontliketoseealloftheinformationsubmittedintheaddresslinkbox.(RelatedArticle!PassingDataBetweenASPPages)
FILE:makin.html
Thisfilecontainstheformwherewegetalloftheinformationfromtheuser.Thisinformationwillbeusedtomakethedigitalpostcard.
<form
name="postalsent"
method="post"
action="view.asp?fromn=seeit"
target="_self"
>
.....
<tdwidth="24"valign="bottom">
<fontface="Arial">
<inputtype="radio"value="postal1"name="R1">
</font>
</td>
<tdwidth="140">
<fontface="Arial">
<fontface=3D"Arial">
<inputtype="radio"value="postal2"name="R1">
</font>
</td>
<tdwidth="151">
<fontface="Arial">
<fontface="Arial">
<inputtype="radio"value="postal3"name="R1">
</font>
</td>
<tdwidth="140">
<fontface="Arial">
<fontface="Arial">
<inputtype="radio"value="postal4"name="R1">
......
<INPUTname="nameto"size=18style="LEFT:1px;TOP:2px">
<inputname="emailto"size="18">
<inputname="namefrom"size="18">
<inputname="emailfrom"size="18">
<TEXTAREAcols=18name=messagerows=2></TEXTAREA>
<inputtype="image"name="bseeit"src="http://edu.cnzz.cn/NewsInfo/images/seesentbotton.gif"
border=0height=51width=110>
<tdwidth="32%">
<ahref="makin.htm">
<html>
<body
marginheight="0"
marginwidth="0"
topmargin="0"
leftmargin="0"
background="images/something.gif"
bgcolor="#002400"
text="#FCC403"
>
<%
Atthistimewewillseeiftherehasbeenanerror
Wealsowanttomakesuretheformdataisvalid.
iferring1and(fromn="seeit"orfromn="out")and
session("postal")""then
ifeverythingiscorrectweshowtheinformation
%>
<divalign="left">
<tableborder="0"width="580"cellspacing="0"cellpadding="0">
<tr>
<tdwidth="50%"valign="top"align="left"><br>
<br>
</a>
<ahref="enviado.asp">
</a>
<%
endif
Thiselsewillonlybereachedifthereisnocard
(i.e.thepasswordwasincorrect)Weneedtoshow
anerrormessage.
else
%>
<br><br>
<center>
</center>
<br>
<%
endif
Therearenoerrors.PutthedataintheDB
andsendthelinktothereceiverviaemail.
Ifgoby=1then
SetConn=Server.CreateObject("ADODB.Connection")
conn.open"DSN=postal;"
Setrs=Server.CreateObject("ADODB.Recordset")
Weneedtoinsertarecordintothedatabase
SQLStmt="INSERTINTOPostcard("&_
"passw,postal,nameto,namefrom,"&_
"emailfrom,emailto,message,data)"&_
"VALUES("
Weneedarandomnumberforourpassword,so
userandomize/rndtomakearandomnumber.
randomize()
passw=Int((9999-1)*Rnd+1)
SQLStmt=SQLStmt&passw&","&session("postal")&_
","&session("nameto")&","&_
session("namefrom")&","&_
session("emailfrom")&","&_
session("emailto")&","&_
session("message")&","&session("data")&")"
Writeinformationtodatabase
rs.OpenSQLStmt,Conn
NowyouwillseehowtousetheFreePersits
E-Mailcomponent
First,CreatetheMailobject
SetMail=Server.CreateObject("Persits.MailSender")
Putthemailserveryouareusing
Mail.Host="mail.mailserver.com"
Sendtheinformationofthe
personthatissendingthee-mail
Mail.From=session("emailfrom")
Whoyouresendingtheemailto.
Mail.FromName=session("namefrom")
Puttheemailtosendto,aswellasthenameoftheperson
Mail.AddAddresssession("emailto"),session("nameto")
Subjectoftheemail
Mail.Subject="DigitalPostCardto"&session("nameto")
Printthebodyoftheemail
enviar="Letmeinformyouthat"&session("namefrom")&_
Chr(13)&Chr(10)&_
"havesentyouadigitalcard.Tosee"&_
"itfollowthelink:"&_
Chr(13)&Chr(10)&Chr(13)&Chr(10)&_
"http://www.???????.com/view.asp?fromn=out&"&_
"ident="&identifier&_
"&psw="&passw&""&Chr(13)&Chr(10)&_
"yourcardisavailabletilltheday"&_
formatDateTime(d,2)&_
Chr(13)&Chr(10)&Chr(13)&Chr(10)&_
Chr(13)&Chr(10)&_
"Thanks"
Mail.Body=enviar
Justskipifthereareanyerrors...
OnErrorresumeNext
Thiswillsendtheemail
Mail.Send
Displayanerrormessageiftherewasanerror
IfErr0Then%>
</a>
</center>
</strong></small></font>
</body>
</html>
GettheE-Mailfreecomponent:http://www.aspemail.com/
Letmeexplainhowtosetitup.Putthecomponentwhereveryouwant,IusuallyputthecomponentsIuse
inthedirectoryC:Inetpubcomponents.Thenregisterit(afteryouputitinthedirectoryyouwant)by
typing:
regsvr32AspEmail.dll
fromthecommandline.Thatsall!Remember,theemailcodewontworkunlessyouregisterthecomponent!
Ifyouhaveanyquestions,pleasecontactme:http://www.4guysfromrolla.com/webtech/joao.shtml
asp对于服务器的要求较高,一般的服务器如果访问量一大就垮了,不得不重启。 |
|