ASP教程之利用ASPMail组件发送数字卡片
优点:简单易学、开发速度快、有很多年“历史”,能找到非常多别人做好的程序来用、配合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对于服务器的要求较高,一般的服务器如果访问量一大就垮了,不得不重启。 作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。 不能只是将它停留在纸上谈兵的程度上。 ASP的语言不仅仅只是命令格式差不多,而是包含在<%%>之内的命令完全就是VB语法。虽然ASP也是做为单独的一个技术来提出的,但他就是完全继承了VB所有的功能。 ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题: 如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助: 哪些内置对象是可以跳过的,或者哪些属性和方法是用不到的? 以HTML语言整合(HTML负责界面上,ASP则负责功能上)形成一个B/S(浏览器/服务器)模式的网页程序。 我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标.
页:
[1]