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")
原文:http://www.enun.net/?p=1199