在记事本中输入下面的代码,设置好数据库与邮件服务器,保存为.vbs文件,将其放置于指定服务器,执行之。 Dim objSendMail Dim strTo, strFrom Dim strSubject, strBody Set objSendMail = CreateObject("CDO.Message") objSendMail.From = "codingtaoist@myspace.com" set mySourceConn = CreateObject("ADODB.Connection")set mySourceRecordset = CreateObject("ADODB.Recordset")mySourceConn.Open = "Provider=SQLOLEDB.1;Data Source=10.99.182.88; Initial Catalog=TestDB;user id = 'sa';password='123"mySQLCmdText = "select * from testtb"mySourceRecordset.Open mySQLCmdText, mySourceConn, 1for countr=1 to mySourceRecordset.RecordCount myname = mySourceRecordset.Fields("myname").value objSendMail.To = myname objSendMail.Subject = "Test email" objSendMail.HtmlBody = "hello codingtaoist" objSendMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.99.182.52" objSendMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 objSendMail.Configuration.Fields.Update objSendMail.Send() mySourceRecordset.MoveNextNextSet objSendMail = Nothing MsgBox("发送成功")