当前位置: 移动技术网 > IT编程>脚本编程>VBScript > VBS获取外网IP地址并发送到指定邮箱的代码

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

2017年12月08日  | 移动技术网IT编程  | 我要评论

收索引擎,闯关东李幼斌版,赛富通首选圣矢

复制代码 代码如下:

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网