如何在页面中对不同的数据进行相同的处理?

时间:2010-06-26 12:30:00 

如何在页面中对不同的数据进行相同的处理?

selectId.asp

' 列出所有客户的客户名称
<html>
<head>
<title>客户名单 - asp之家 www.aspxhome.com</title>
</head><
body>
<p align=center><font style="font-family:宋体;font-size:9pt">
请选择要给发送的电子邮件的客户:
<form method="POST" action="SendMail.asp">
<%
Set dbConnection = Server.CreateObject("ADODB.Connection")
dbConnection.open "Driver={Microsoft Access Driver (*.mdb)};"&_
"DBQ=C:\inetpub\wwwroot\test\Email.mdb"
' 建立与Access数据库的连接
Set rsCustomers = Server.CreateObject("ADODB.RecordSet")
rsCustomers.Open "Select CustomerId,CustomerName,CustomerEmail From 
EmailList",_
' 获取所有客户的客户编号、客户名称
                dbConnection,1,3,1
while not rsCustomers.eof
' 显示所有客户的客户名称
%>
<br><input type="checkbox" name="CustomerId" value="<%=rsCustomers("CustomerId")%>">
<a href="mailto:<%=rsCustomers("CustomerEmail")%>">
<%=rsCustomers("CustomerName")%></a>
<%rsCustomers.MoveNext
wend
rsCustomers.close
set rsCustomers = nothing
dbConnection.close
set dbConnection = nothing
%>
<br><input type="submit" value="发信" name="B1" style="font-family:宋体;font-size:9pt">
</form>
</body>
</html>

sendmail.asp

' 给所选择客户发电子邮件
<html>
<head>
<title>精彩春风之发送邮件</title>
</head>
<body>
<p align=center>
邮件正在发送中!请稍候...
<%
Set dbConnection = Server.CreateObject("ADODB.Connection")
dbConnection.open "Driver={Microsoft Access Driver (*.mdb)};"&_
"DBQ=C:\inetpub\wwwroot\test\Email.mdb"
' 建立与Access数据库的连接
Set rsCustomers = Server.CreateObject("ADODB.RecordSet")
rsCustomers.Open "Select CustomerName,CustomerEmail From EmailList 
' 获取所选择客户的电子信箱
where CustomerId in ("&_
                  Request("CustomerId")&")",dbConnection,1,3,1
while not rsCustomers.eof
Set myMail = CreateObject("CDONTS.NewMail") 
myMail.From = "chunfeng@intels.net"
myMail.value("Reply-To") = "chunfeng@intels.net"
myMail.To = rsCustomers("CustomerEmail")
myMail.Subject = "来自随风起舞的问候!" 
myMail.BodyFormat = 1
myMail.MailFormat = 1  
myMail.Body = "精彩春风恭祝"&rsCustomers("CustomerName")&"幸福平安,工作顺利!"
myMail.Send 
' 给客户发邮件
Set myMail = Nothing 
%>
<br>
<ahref="恭喜,已成功给:<%=rsCustomers("CustomerEmail")%>"> <%=rsCustomers("CustomerName")%></a>发送电子邮件!
<%
rsCustomers.MoveNext
wend
rsCustomers.close
set rsCustomers = nothing
dbConnection.close
set dbConnection = nothing
%>
<br>恭喜,已成功给所有选择的客户发送邮件完毕!
</body>
</html>

标签:数据,asp
0
投稿

猜你喜欢

  • 如何把图片也存到数据库中去?

    2009-11-06 13:56:00
  • 17个asp常用的正则表达式

    2008-01-15 18:58:00
  • HTML 5 胜出:XHTML2 宣告夭折

    2009-07-12 15:23:00
  • 利用WSH获取计算机硬件信息、DNS信息等

    2008-05-05 13:04:00
  • ajax返回中文乱码问题解决

    2009-04-13 16:07:00
  • 使用javascript修复浏览器中12个常见而又头痛的问题

    2008-10-28 19:38:00
  • 解决MSSQL下“不能在手动或分布事务方式下创建新的连接”的问题

    2008-07-15 12:48:00
  • SQL Server数据体系和应用程序逻辑详解

    2009-04-14 07:23:00
  • 一个用Ajax做的用户名验证程序

    2007-10-21 20:40:00
  • 最新的关键SQL Server漏洞已被微软证实

    2009-03-16 14:31:00
  • 为google量身定做的sitemap生成代码asp版

    2011-04-06 10:43:00
  • 关于DOM元素定位属性的深入学习

    2008-04-02 11:46:00
  • asp如何对文件进行操作?

    2009-11-20 18:31:00
  • 从MySQL4.0向MySQL5迁移数据

    2007-11-19 13:11:00
  • MySQL 数值类型概述int smallint tinyint

    2010-11-02 11:46:00
  • 何时将数据装载到Application 或 Session 对象中去?

    2009-12-03 20:17:00
  • debug case: onsubmit=return false依然能提交

    2009-01-18 13:07:00
  • 多栏自适应布局问题浅谈

    2010-08-16 12:56:00
  • HTML5 第二份草案发布

    2008-06-17 17:42:00
  • JS 中如何判断 null

    2007-12-13 20:28:00
  • asp之家 网络编程 m.aspxhome.com