如何用Delphi开发简单的WebMail程序

如何用Delphi开发简单的WebMail程序,第1张

WebMail是指在网页中实现邮件的发送 使用Delphi开发Web Server程序是非常简单的 Delphi中提供了大量的元件和对象 下面通过一个例子来介绍如何利用Delphi开发一个响应用户输入的ISAPI的WebMail程序 为了简单 程序没有对传送的数据提供保密

首先 在Web服务器端安装数据库引擎dbe 并设置好数据库别名 yh 指向一个包含用户名和用户密码的数据库文件user db 接着建立两个HTML文件 名字分别为 dl qd 放在Web服务器的缺省目录下(如 c \inetpub\root)

dl 的内容如下

<><head><title>发送邮件系统</title></head><body><h >发送邮件系统</h ><p>请输入您的用户名及密码</p><form method= post action= /scripts/SendMail ><p>用户名<input type= text length= name= username >密码 <input type= password length= name= password ></p><p><input type= submit value= 确定 ><input type= reset value= 清除 ></p></form></body></> qd 文件内容如下

<><head><title>填表</title></head><body><form method= post action= feedback ><p>请填入接收邮件地址:toaddress:<input type= text length= name= toaddress ></p><p>请填入主题<input type= text length= name= subject ></p><p>内容 </p><p><input type= textarea length= width= name= body ></p><p><input type= submit value= 确定 ><input type= reset value= 清除 ></p></form ></body ></ > 在Delphi中新建一个基于ISAPI的Web Server Application 手动增加nm *** tp query pageproducer 其中 pageproducer 的file属性为c:\inetpub\ root\qd nm *** tp 的host(发送邮件服务器的地址)在这里为 *** tp netease port: 全局变量为 sername:stringflag:boolean

增加一个路径为feedback的动作项 其代码如下

 Var Count:integerS:string BeginQuery closeQuery sql clearS:= select count(username) from user dbswheresusername= S:=s+request contentfields values[ username ]+ S:=s+ and password= S:=s+request contentfields values[ psword ]+ Query sql add(S)Query openIf query count= then response content:= <><head><title></title><body>用户名 密码不正确 请重新输入</body></>Else Username:=request contentfields values[ username ]Response content:=pageproducer contentEnd 再增加一个路径为Sendmail的动作项 它的程序代码如下

Var body:stringBeginFlag:=truebody:=request contentfields values[ body ]Pageproducer doc clearPageproducer doc add( <><body >)Nm *** tp postmessage clearNm *** tp postmessage fromaddress:=username+ @netease Nm *** tp postmessage from:=usernameNm *** tp postmessage body add(body)Nm *** tp postmessage toaddress add(request contentfields values[ toaddress ])Nm *** tp postmessage subject:=request contentfields values[ subject ] Nm *** tp connectIf flag=true then beginNm *** tp sendmailnm *** tp disconntentendpageproducer doc add( </body></>)response content:=pageproducer contentend 增加nm *** tp 的OnConnect事件添加如下代码

lishixinzhi/Article/program/Delphi/201311/24974

原因如下:1,在关机前断网,关闭所有运行的程序(包括后台非系统进程)然后关机,看看问题还存不存在。2.如果问题不存在了,就逐一排查关机前关闭了的软件的兼容问题,直到找到问题为止。3.如果问题依旧存在,就很有可能系统文件被破坏了4.想想最近新装什么软件没有,如果有,就把卸载重安。5,如果使用盗版系统,有可能会出现这样的问题,建议使用正版。6,病毒引起的,升级杀毒软件,对电脑全盘杀毒。7,硬件上的原因,主要是内存条不兼容引起的,把内存条拆下重新安装,必要时更换内存8,系统或其它软件引起的,安装的软件与系统发生冲突,(一般的解决办法就是卸载该软件重新安装、升级或更换其它版本,不行只有卸载该软件,问题才能解决)。9,驱动不稳定,重新安装或及时更新驱动


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/11418655.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存