网络编程
位置:首页>> 网络编程>> Asp编程>> 如何在页面中对不同的数据进行相同的处理?

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

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

标签:数据,asp

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

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>

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com