-
- Const WshRunning = 0
- Set objEmail = CreateObject("CDO.Message")
- Set objShell = CreateObject("WScript.Shell")
- Set objExec = objShell.Exec("ipconfig /al")
- Do While objExec.Status = WshRunning
- WScript.Sleep 100
- Loop
- If objExec.ExitCode = 0 Then
- Call SendMail("user@163.com","user@hotmail.com","命令执行成功",_
- "命令执行成功","smtp.163.com","user","password")
- Else
- strErrorMsg = objExec.StdOut.ReadAll
- Call SendMail("user@163.com","user@hotmail.com;user@163.com","命令执行失败",_
- strErrorMsg,"smtp.163.com","user","password")
- End If
-
- Sub SendMail(strFrom,strTo,strSubject,strBody,strSMTPServer,strUser,strPassword)
- objEmail.From = strFrom '发件人
- objEmail.To = strTo '收件人
- objEmail.Subject = strSubject '主题
- objEmail.Textbody = strBody '内容
- objEmail.Configuration.Fields.Item _
- ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
- objEmail.Configuration.Fields.Item _
- ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
- strSMTPServer
- objEmail.Configuration.Fields.Item _
- ("http://schemas.microsoft.com/cdo/configuration/sendusername") = strUser '用户名
- objEmail.Configuration.Fields.Item _
- ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strPassword '密码
- objEmail.Configuration.Fields.Item _
- ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 '明文验证
- objEmail.Configuration.Fields.Item _
- ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 '加密连接
- objEmail.Configuration.Fields.Item _
- ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
- objEmail.Configuration.Fields.Update
- objEmail.Send
- End Sub
复制代码
这个是我找到的,是vbs脚本~大家参考参考哈~
谢谢管理员给的例子,我研究去咯~
[ 本帖最后由 jijo 于 2009-12-20 23:17 编辑 ] |