仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 488|回复: 8
打印 上一主题 下一主题

[学习教程] ASP教程之利用ASPMail组件发送数字卡片

[复制链接]
爱飞 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:33:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

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对于服务器的要求较高,一般的服务器如果访问量一大就垮了,不得不重启。
飘飘悠悠 该用户已被删除
沙发
发表于 2015-1-17 23:12:39 | 只看该作者
作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。
admin 该用户已被删除
板凳
发表于 2015-1-18 09:47:14 | 只看该作者
不能只是将它停留在纸上谈兵的程度上。
蒙在股里 该用户已被删除
地板
发表于 2015-1-21 16:14:09 | 只看该作者
ASP的语言不仅仅只是命令格式差不多,而是包含在<%%>之内的命令完全就是VB语法。虽然ASP也是做为单独的一个技术来提出的,但他就是完全继承了VB所有的功能。
若天明 该用户已被删除
5#
发表于 2015-1-30 20:51:43 | 只看该作者
ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题:
愤怒的大鸟 该用户已被删除
6#
发表于 2015-2-6 15:56:06 | 只看该作者
如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助:
老尸 该用户已被删除
7#
发表于 2015-2-16 23:26:58 | 只看该作者
哪些内置对象是可以跳过的,或者哪些属性和方法是用不到的?
再现理想 该用户已被删除
8#
发表于 2015-3-5 12:36:53 | 只看该作者
以HTML语言整合(HTML负责界面上,ASP则负责功能上)形成一个B/S(浏览器/服务器)模式的网页程序。
金色的骷髅 该用户已被删除
9#
发表于 2015-3-19 18:37:10 | 只看该作者
我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-23 06:05

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表