'Use VBS to write a script, and then use the scheduled tasks on the WINDOWS platform to call it. Send emails to the group regularly on a daily basis.
'Code: http://www.51tiao.com/info.vbs
Copy codeThe Code is as follows: 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 'Error continues execution
'Mail content
Msg = "& "<Meta name =" "Author" "CONTENT =" "Breeze, 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> today's recommendation information" & Year (Date () & "Year" & Month (Date ()) & "month" & Day (Date ()) & "day <a href =" "http://www.51tiao.com" "target =" "_ blank" "> <FONT size = 3> <B> Shanghai flea market </B> </font> </a> </td> </tr> </table> </div> </td> </tr> </table> "& VBCRLF _
& "<Table width = 640>" & VBCRLF _
& "<Tr bgColor = '# FF9D5C'> <td height = 3> </td> </tr> <tr> "& VBCRLF _
& "<Td>" & VBCRLF _
& "<Ul>" & VBCRLF _
& "<P>"
SQL = "select distinct top 100 a. infoid, a. Strtitle from newinfoarticle "_
& "Inner join Newinfoprop B "_
& "On. infoid = B. infoid and. intgood = 1 and. intshenhe = 1 and B. rid1 = 908 and datediff (d, createtime, getdate () = 0 "_
& "Order by a. infoid desc"
Set rs = conn.exe cute (SQL)
If rs. eof Then
Wscript. Echo "no record! "
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> <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> </body>
'Get the email address
Dim I, total, jmail
I = 1
Dim BadMail 'recipient List format: 'email address', 'email address'
BadMail = "'2017 @ 163.com ', '2017 @ 126.com '"
SQL = "Select distinct B. stremail From userinfo a inner join userinfo_1 B "_
& "On. id = B. intuserid and B. stremail <> ''and (charindex ('3',. struserLevel)> 0 or charindex ('4',. 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 "no user! "
Rs. close: Set rs = Nothing
Exit Sub
End If
'Send every 20 email addresses
For I = 1 To total
If I Mod 20 = 1 Then
Set jmail = CreateObject ("JMAIL. Message") 'creates the email sending object.
'Jmail. silent = true' to block exception errors. The values FALSE and true are returned.
Jmail. Logging = true' logs
Jmail. Charset = "GB2312" 'text encoding of the email
Jmail. ContentType = "text/html" 'the mail format is HTML or plain text
End If
Jmail. AddRecipient rs (0)
If I Mod 20 = 0 Or I = 665 Then
Jmail. From = "info At 51 tiao" 'sender's E-MAIL address
Jmail. FromName = "Shanghai flea market" 'sender's name
Jmail. MailServerUserName = "info" 'user name used to log on to the email server (your email address)
Jmail. MailServerPassword = "123123" 'password for logging on to the email server (your email password)
Jmail. subject = "Shanghai flea market today's recommendation" & Year (Date () & "Year" & Month (Date () & "Month" & Day (Date ()) & "day" 'mail title
Jmail. Body = msg 'mail content
Jmail. Priority = 3' urgent mail program. 1 is the fastest, 5 is the slowest, and 3 is the default.
Jmail. Send ("mail.51tiao.com") 'executes the mail sending (via the mail server address)
Jmail. Close ()
Set jmail = Nothing
End If
Rs. movenext
Next
Rs. close: Set rs = Nothing
'Record the log in C: \ jmail.
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 "the email is successfully sent. A total of" & total & "emails are sent to" & Now () & "<Br>"
Txt. Write jmail. log
Set txt = Nothing
Set fso = Nothing
Wscript. Echo "the email is successfully sent. A total of" & total & "emails are sent to" & Now ()
End Sub
Sub CloseDB ()
If IsObject (conn) Then
Conn. close: Set Conn = Nothing
End If
End Sub