获取外网IP并发送到指定邮箱的vbs代码[已测]_vbs教程-查字典教程网
获取外网IP并发送到指定邮箱的vbs代码[已测]
获取外网IP并发送到指定邮箱的vbs代码[已测]
发布时间:2016-12-28 来源:查字典编辑
摘要:复制代码代码如下:''getIPsethttp=createobject("Microsoft.XMLHTTP")ipp="http://w...

复制代码 代码如下:

''getIP

set http=createobject("Microsoft.XMLHTTP")

ipp="http://www.ip138.com/ip2city.asp"

http.open "get",ipp,false

http.send

ss=bytes2BSTR(Http.responsebody)

intStrA = InStr(1,ss,"[",1)+1

sss=mid(ss,intStrA)

intStrB = InStr(1,sss,"]",1)-1

ss=mid(ss,intStrA,intStrB)

'wscript.echo ss

Function bytes2BSTR(vIn)

strReturn = ""

For i = 1 To LenB(vIn)

ThisCharCode = AscB(MidB(vIn,i,1))

If ThisCharCode < &H80 Then

strReturn = strReturn & Chr(ThisCharCode)

Else

NextCharCode = AscB(MidB(vIn,i+1,1))

strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))

i = i + 1

End If

Next

bytes2BSTR = strReturn

End Function

''SendEmail

NameSpace = "http://schemas.microsoft.com/cdo/configuration/"

Set Email = CreateObject("CDO.Message")

Email.From = "发送邮箱"

Email.To = "接收邮箱"

Email.Subject = "主题"

Email.Textbody =ss&date() 'ss为获取到的ip

'Email.AddAttachment "附件的路径例如:C:foo.zip"

With Email.Configuration.Fields

.Item(NameSpace&"sendusing") = 2

.Item(NameSpace&"smtpserver") = "smtp.163.com" 'smtp服务器地址

.Item(NameSpace&"smtpserverport") = 25

.Item(NameSpace&"smtpauthenticate") = 1

.Item(NameSpace&"sendusername") = "账户名,发送邮箱的"

.Item(NameSpace&"sendpassword") = "密码"

.Update

End With

Email.Send

注意代码中的参数设置。

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新vbs学习
    热门vbs学习
    脚本专栏子分类