VBS中怎么获取外网IP地址并发送到指定邮箱,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
代码如下:
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地址并发送到指定邮箱问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。