首頁  >  文章  >  web前端  >  VBS取得外網IP位址並傳送到指定信箱的代碼

VBS取得外網IP位址並傳送到指定信箱的代碼

高洛峰
高洛峰原創
2017-01-16 09:56:332090瀏覽

Function GetIPAddress()
 Dim Flag, Source
 Set GetIPObj = WScript.GetObject("http://ipseeker.cn//")
 Flag = 0
 For i=1 To 10
    If GetIPObj.readyState = "complete" Then 
    Flag=1
    Exit For
    End If
    WScript.Sleep 500
 Next
 If Flag = 0 Then
  GetIPAddress = "Get IP Address Time Out ..."
 Else
  Source = GetIPObj.documentElement.innerText
  Set Rep = New RegExp
  Rep.Pattern="(\d+)\.(\d+)\.(\d+)\.(\d+)"
  For Each result in Rep.Execute(Source)
    GetIPAddress = result
    Exit For
  Next
 End If
End Function
Function MailTo(MailAddress)
    Dim NameSpace, MailObject

    NameSpace = "http://schemas.microsoft.com/cdo/configuration/"

    Set MailObject = CreateObject("CDO.Message")
    MailObject.From = "*****@21cn.com"
    MailObject.To = MailAddress
    MailObject.Subject = "IP Address Information"

    MailObject.Textbody = Now & ": " & GetIPAddress()

    MailObject.Configuration.Fields.Item(NameSpace & "sendusing") = 2
    MailObject.Configuration.Fields.Item(NameSpace & "smtpserver") = "smtp.21cn.com"
    MailObject.Configuration.Fields.Item(NameSpace & "smtpserverport") = 25
    MailObject.Configuration.Fields.Item(NameSpace & "smtpauthenticate") = 1
    MailObject.Configuration.Fields.Item(NameSpace & "sendusername") = "*****"
    MailObject.Configuration.Fields.Item(NameSpace & "sendpassword") = "*****"

    MailObject.Configuration.Fields.Update
    MailObject.Send
End Function
MailTo ("******@qq.com")

更多VBS取得外網IP位址並發送到指定郵箱的代碼相關文章請關注PHP中文網!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn