本篇內(nèi)容介紹了“vbs如何實(shí)現(xiàn)定時發(fā)送郵件”的有關(guān)知識,在實(shí)際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
鎮(zhèn)坪網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),鎮(zhèn)坪網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為鎮(zhèn)坪上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站制作要多少錢,請找那個售后服務(wù)好的鎮(zhèn)坪做網(wǎng)站的公司定做!'用VBS寫個腳本,然后用WINDOWS平臺下的計(jì)劃任務(wù)來調(diào)用,每天定時群發(fā)郵件.
'代碼如下: 下載地址 http://www.51tiao.com/info.vbs
復(fù)制代碼 代碼如下:
Dim connstr,conn
Dim sql,rs,msg
Sub OpenDB()
ConnStr = "DSN=51tiao.Com;UID=sa;PWD=;"
If Not IsObject(Conn) Then
Set conn = CreateObject("Adodb.Connection")
Conn.Open ConnStr
End If
End Sub
OpenDB()
Send()
CloseDB()
Sub Send()
On Error Resume Next '有錯繼續(xù)執(zhí)行
'郵件內(nèi)容
msg = "<html><head><title>上海跳蚤市場今日推薦 "&Date()&"</title>"&VBCRLF _
&"<META NAME=""Author"" CONTENT=""清風(fēng), QQ: 110125707, MSN: anwellsz@msn.com"">"&VBCRLF _
&"<style type='text/css'>"&VBCRLF _
&"<!--"&vbcrlf _
&"td,form,select,input,p,table,.font {font-size: 12px;line-height: 20px}"&VBCRLF _
&"a:link { color: #000000; font-size: 12px; text-decoration: none}"&VBCRLF _
&"a:visited { color: #000000; font-size: 12px; text-decoration: none}"&VBCRLF _
&"a:hover { color: #ff7f2c; font-size: 12px; text-decoration: underline}"&VBCRLF _
&"-->"&VBCRLF _
&"</style>"&VBCRLF _
&"</head><body>"&VBCRLF _
&"<table width=640>"&VBCRLF _
&"<tr><td align=right>今日推薦信息 "&Year(Date())&"年"&Month(Date())&"月"&Day(Date())&"日 <a href=""http://www.51tiao.com"" target=""_blank""><FONT size=3><b>上海跳蚤市場</b></font></a> </td></tr></table></div></td></tr></table>"&VBCRLF _
&"<table width=640>"&VBCRLF _
&"<tr bgColor='#FF9D5C'><td height=3></td></tr><tr><td> </td></tr><tr>"&VBCRLF _
&"<td>"&VBCRLF _
&" <ul>"&VBCRLF _
&" <p>"
sql = "select distinct top 100 a.infoid,a.Strtitle from newinfoarticle a "_
&"inner join Newinfoprop b "_
&"on a.infoid = b.infoid and a.intgood = 1 and a.intshenhe = 1 and b.rid1 = 908 and datediff(d,createtime,getdate())=0 "_
&"order by a.infoid desc"
Set rs = conn.execute(sql)
If rs.eof Then
Wscript.Echo "沒有記錄!"
rs.close : Set rs = Nothing
Exit Sub
End If
Do While Not rs.eof
msg = msg&"★ <a href=""http://www.51tiao.com/4/Show.asp?ID="&rs("infoid")&""" title = """&rs("strtitle")&""" target=""_blank"">"_
&rs("Strtitle")&"</a><br>"&VBCRLF
Rs.MoveNext
Loop
Rs.close : set Rs=Nothing
msg = msg & "</ul></p>"&VBCRLF _
&"</td>"&VBCRLF _
&"</tr><tr><td> </td></tr><tr bgColor='#FF9D5C'><td height=3></td></tr>"&VBCRLF _
&"<tr align=right><td><a href=""http://www.51tiao.com"" target=""_blank""><FONT face='Arial Black' size=3>51Tiao.Com</FONT></a> </td></tr>"&VBCRLF _
&"</table><p></p></body></html>"
'取得郵件地址
Dim i,total,jmail
i = 1
Dim BadMail '不接收的郵件列表 格式 '郵件地址','郵件地址'
BadMail = "'123@163.com','122@126.com'"
sql = "Select distinct b.stremail From userinfo a inner join userinfo_1 b "_
&"on a.id = b.intuserid and b.stremail <> '' and (charindex('3',a.StruserLevel)>0 or charindex('4',a.StruserLevel)>0) "_
&"and b.stremail not in ("&BadMail&") "_
&"order by b.stremail"
Set rs = CreateObject("Adodb.Recordset")
rs.open sql,conn,1,1
total = rs.recordcount
If rs.eof Then
Wscript.Echo "沒有用戶!"
rs.close : Set rs = Nothing
Exit Sub
End If
'每二十個郵件地址發(fā)送一次
For i = 1 To total
If i Mod 20 = 1 Then
Set jmail = CreateObject("JMAIL.Message") '建立發(fā)送郵件的對象
'jmail.silent = true '屏蔽例外錯誤,返回FALSE跟TRUE兩值
jmail.Logging = True '記錄日志
jmail.Charset = "GB2312" '郵件的文字編碼
jmail.ContentType = "text/html" '郵件的格式為HTML格式或純文本
End If
jmail.AddRecipient rs(0)
If i Mod 20 = 0 Or i = 665 Then
jmail.From = "info At 51tiao" '發(fā)件人的E-MAIL地址
jmail.FromName = "上海跳蚤市場" '發(fā)件人的名稱
jmail.MailServerUserName = "info" '登錄郵件服務(wù)器的用戶名 (您的郵件地址)
jmail.MailServerPassword = "123123" '登錄郵件服務(wù)器的密碼 (您的郵件密碼)
jmail.Subject = "上海跳蚤市場今日推薦 "&Year(Date())&"年"&Month(Date())&"月"&Day(Date())&"日" '郵件的標(biāo)題
jmail.Body = msg '郵件的內(nèi)容
jmail.Priority = 3 '郵件的緊急程序,1 為最快,5 為最慢, 3 為默認(rèn)值
jmail.Send("mail.51tiao.com") '執(zhí)行郵件發(fā)送(通過郵件服務(wù)器地址)
jmail.Close()
set jmail = Nothing
End If
rs.movenext
Next
rs.close : Set rs = Nothing
'記錄日志在C:\jmail年月日.txt
Const DEF_FSOString = "Scripting.FileSystemObject"
Dim fso,txt
Set fso = CreateObject(DEF_FSOString)
Set txt=fso.CreateTextFile("C:\jmail"&DateValue(Date())&".txt",true)
txt.Write "郵件發(fā)送成功,共發(fā)送了"&total&"封郵件,發(fā)送于 "&Now()&"<Br><Br>"
txt.Write jmail.log
Set txt = Nothing
Set fso = Nothing
Wscript.Echo "郵件發(fā)送成功,共發(fā)送了"&total&"封郵件,發(fā)送于 "&Now()
End Sub
Sub CloseDB()
If IsObject(conn) Then
Conn.close : Set Conn = Nothing
End If
End Sub
“vbs如何實(shí)現(xiàn)定時發(fā)送郵件”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
當(dāng)前名稱:vbs如何實(shí)現(xiàn)定時發(fā)送郵件-創(chuàng)新互聯(lián)
路徑分享:http://bm7419.com/article32/dscjpc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、網(wǎng)站改版、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站維護(hù)、App開發(fā)、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容