欢迎来到入门教程网!

vb

当前位置:主页 > 软件编程 > vb >

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

来源:本站原创|时间:2020-01-10|栏目:vb|点击:

复制代码 代码如下:

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")



原文:http://www.enun.net/?p=1199

上一篇:VBS 加解密 For CAPICOM

栏    目:vb

下一篇:VBSCript之GenerateSDDL函数(权限设置)

本文标题:VBS获取外网IP地址并发送到指定邮箱的代码

本文地址:https://www.xiuzhanwang.com/a1/vb/7313.html

网页制作CMS教程网络编程软件编程脚本语言数据库服务器

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:835971066 | 邮箱:835971066#qq.com(#换成@)

Copyright © 2002-2020 脚本教程网 版权所有