当前位置: 代码迷 >> ASP >> 帮小MM讲讲这段代码应该怎么用?
  详细解决方案

帮小MM讲讲这段代码应该怎么用?

热度:79   发布时间:2012-02-20 21:18:23.0
帮小MM讲讲这段代码应该如何用??
<%

if   request( "Page ")= " "   then  
CPage=1
else  
Cpage=request( "Page ")
end   if
'接受邮件内容,当然,也可以从数据库种查询
comment=request( "comment ")
'定义邮件数组
Dim   emailArray
sql_email= "SELECT   useremail,userregname,userpassword     FROM   email "
Set   Recordsetemail=Server.CreateObject( "ADODB.Recordset ")
Recordsetemail.ActiveConnection=cnn
Recordsetemail.Source=sql_email
Recordsetemail.CursorType=3
Recordsetemail.CursorLocation=2
Recordsetemail.LockType=1
Recordsetemail.Pagesize=5
Recordsetemail.Open()
Recordsetemail.AbsolutePage=CPage
Page_Count=Recordsetemail.PageCount
'把数据库中的读取到数组中。
emailArray=Recordsetemail.Getrows(5,0)
Recordsetemail.close
if   err.number <> 0   then
JMail.Close
response.write   "邮件群发成功! "
response.end
else

end   if

set   Recordsetemail=nothing
if   isarray(emailArray)   then
  Repeat1__index=0
  dim   U_emailArray
  U_emailArray=ubound(emailArray,2)
  While(Repeat1__index <=U_emailArray)  
    comment1=replace(comment, " </user> ",emailarray(1,Repeat1__index))
    comment1=replace(comment1, " </password> ",emailarray(2,Repeat1__index))
        Set   JMail=Server.CreateObject( "JMail.SMTPMail ")  
        JMail.ContentType= "text/html "  
        JMail.Encoding   =   "base64 "  
        JMail.Charset= "gb2312 "  
        jmail.Sender=request( "fromwho ")
        JMail.Subject   =   request( "subject ")
        JMail.AddRecipient(emailarray(0,Repeat1__index))  
        JMail.Body   =comment1
        JMail.AddHeader   "Originating-IP ",   Request.ServerVariables( "REMOTE_ADDR ")  


        JMail.Execute  
        JMail.Close
        response.Write(request( "ToWho "))
        response.Write( "   成功发送! <BR> ")
        Set   JMail   =   Nothing  

    Repeat1__index=Repeat1__index+1
  wend
else

end   if

Recordset1.Close()
Set   Recordset1   =   Nothing
'构建一个自身请求自身的方法
response.redirect   "email_sendall.asp?page= "&(cpage+1)& "subject= "&request( "subject ")& "fromwho= "&request( "fromwho ")& "comment= "&comment
%>

  这段代码,想必大家都见过吧,小MM比较菜,有几点不太明白:
1.这里用来发送邮件的用户名和密码是哪个呢>
2.以及具体这代码通过数组来群发有原理!
3.谢谢!

------解决方案--------------------
==================================
<%
Dim JMail,SendMail,RsMail,RsInfo
set rsinfo=conn.execute( "select * from mailarticle where a_id= "& request( "id "))
if rsinfo.eof then
response.Write( "发送信息不存在! ")
response.End()
else
rsinfoA_title=rsinfo( "A_title ")
rsinfoA_content=rsinfo( "A_content ")
  相关解决方案