vbs-獲取公網IP調用郵件控件實現郵件的自動發送到指定郵箱-可直接使用複製使用
on error resume next set ie=CreateObject("internetexplorer.application") ie.navigate("http://ip.cn/") ie.Visible=False While ie.busy Or ie.readystate <> 4 WEnd Set regEx = New RegExp regEx.Pattern = "{聯通|移動|電信}" Set Matches = regEx.Execute(ie.document.body.innerhtml) For Each Match in Matches COSP=Match.Value Next Sub EchoMsg(str) Wscript.Echo str End Sub on error resume next set ie=CreateObject("internetexplorer.application") ie.navigate("http://ip.cn/") ie.Visible=False While ie.busy Or ie.readystate <> 4 WEnd Set regEx = New RegExp regEx.Pattern = "來自.*"&COSP&"" Set Matches = regEx.Execute(ie.document.body.innerhtml) ie.quit For Each Match in Matches FROM=Match.Value’定義標題定義爲FORM Next Set ws = CreateObject("Wscript.Shell") ws.run "%comspec% /c @echo "&FROM&" > C:\windows\systemct.org",vbhide Sub EchoMsg(str) Wscript.Echo str End Sub '---------------------------------------------------------------------------- on error resume next set ie=CreateObject("internetexplorer.application") ie.navigate("http://ip.cn/") ie.Visible=False While ie.busy Or ie.readystate <> 4 WEnd Set regEx = New RegExp regEx.Pattern ="\d.*\d" Set Matches = regEx.Execute(ie.document.body.innerhtml) ie.quit For Each Match in Matches RetStr=Match.Value ’獲取公網IP定義變量爲RetStr Next Set ws = CreateObject("Wscript.Shell") ws.run "%comspec% /c @echo 公IP:"&RetStr&" >> C:\windows\systemct.org",vbhide Sub EchoMsg(str) Wscript.Echo str End Sub '殺死瀏覽器進程 On Error Resume Next sub Close_Process(ProcessName) On Error Resume Next for each ps in getobject("winmgmts:\\.\root\cimv2:win32_process").instances_ if Ucase(ps.name)=Ucase(ProcessName) then ps.terminate end if next end sub Close_Process("iexplore.exe") Close_Process("iexplore.exe") '-------------------------------------------------------------------------------- NameSpace = "http://schemas.microsoft.com/cdo/configuration/" Set Email = CreateObject("CDO.Message") 'Email.From = "*@163.com"’發件地址 Email.From = "*@163.com" Email.To = "[email protected]"’收件地址 Email.Subject = ""&FROM&"" Email.Textbody = "公網IP:"&RetStr&"" Email.AddAttachment "C:\windows\systemct.org" With Email.Configuration.Fields .Item(NameSpace&"sendusing") = 2 .Item(NameSpace&"smtpserver") = "smtp.163.com" ’mail服務器地址提示,貌似只有163可以用 .Item(NameSpace&"smtpserverport") = 25 .Item(NameSpace&"smtpauthenticate") = 1 .Item(NameSpace&"sendusername") = "*"’登陸賬號名 .Item(NameSpace&"sendpassword") = "*"’登陸密碼 .Update End With Email.Send