最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp批量给用户发送邮箱
时间:2009-10-26 编辑:简简单单 来源:一聚教程网
请选择要操作的项目,提交数据后,将会显示您选择的项目。
当客户端选择了要显示的项目后,下面的ASP页面(Set.ASP)给出客户端选择的项目个数及其值。
<%@ LANGUAGE = VBScript %>
<%
Response.Write "
您一共选择了"&request("MyCheckBox").count&"项,"
Response.Write "
您选择的项目有:"&request("MyCheckBox")
%>
如当客户端选择了第二、三、五项并提交数据后,将会看到如下结果:
您一共选择了3项,
您选择的项目有:2, 3, 5
应该注意到,“2, 3, 5”的形式与SQL语句要求的形式是一致的,我们可以直接或间接地利用这种形式的结果,如 "Select * from ATable where AFiled in(" & request("MyCheckBox") & ")"的实际
SQL查询语句为“Select * from ATable where AFiled in(2, 3, 5)”。
二、HTML的集合属性的应用
下面我们结合一个实际的例子,讨论一下如何在ASP页面中利用HTML的集合属性来成批操作数据库。现在我们有一个记录客户电子信箱的ACCESS数据库EMail,其中有一个数据表EmailList,包含CustomerId、CustomerName、CustomerEmail三个字段,分别表示客户编号、客户名称、客户电子信箱。在ASP页面SelectId.ASP中,我们采用CheckBox列出所有客户的客户名称(各个CheckBox的值为对应的客户编号),让用户选择给哪些客户发送电子邮件。当用户选择了客户并提交数据后,SendMail.ASP将检索到这些客户的电子信箱,并给这些客户发送电子邮件。具体的信息请参见下面ASP程序代码和注释信息。
请选择要给哪些客户发送“新年问候”的电子邮件
正在给下面客户发送电子邮件
<%'建立与ACCESS数据库的连接
Set dbConnection = Server.CreateObject("ADODB.Connection")
dbConnection.open "Driver={Microsoft Access Driver (*.mdb)};"&_
"DBQ=C:/inetpub/wwwroot/test/Email.mdb"
'获取所选择客户的电子信箱
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 = "sales@test.com"
myMail.value("Reply-To") = "sales@test.com"
myMail.To = rsCustomers("CustomerEmail")
myMail.Subject = "来自王发军的新年问候"
myMail.BodyFormat = 1
myMail.MailFormat = 1
myMail.Body = "王发军向"&rsCustomers("CustomerName")&"问好!"
myMail.Send
Set myMail = Nothing
%>
给mailto:<%=rsCustomers("CustomerEmail")%>"><%=rsCustomers("CustomerName")%>
发送电子邮件成功!
<%
rsCustomers.MoveNext
wend
rsCustomers.close
set rsCustomers = nothing
dbConnection.close
set dbConnection = nothing
%>
在所选择的客户发送电子邮件完毕!
-
上一个: asp sql超级防注入代码
-
下一个: asp 生成图片缩略图代码
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14