简要咨询咨询QQ网站导航网站搜索手机站点联系我们设为首页加入收藏 

VBS获取外网IP地址并发送到指定邮箱的代码

来源:易贤网   阅读:1507 次  日期:2014-05-09 16:49:34

温馨提示:易贤网小编为您整理了“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")

更多信息请查看IT技术专栏

更多信息请查看脚本栏目
点此处就本文及相关问题在本站进行非正式的简要咨询(便捷快速)】     【点此处查询各地各类考试咨询QQ号码及交流群
上一篇:VBS 获取外网IP的实现代码
下一篇:VBS 加解密 For MS Script Encode
易贤网手机网站地址:VBS获取外网IP地址并发送到指定邮箱的代码
由于各方面情况的不断调整与变化,易贤网提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!