How to use vbs to get a public network IP and send it to a specified mailbox
This article mainly shows you "how to use vbs to obtain the public network IP and send it to the designated mailbox", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use vbs to obtain the public network IP and send to the designated mailbox" this article.
The code is as follows:
'' 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 = "send mailbox"
Email.To = "receive mailbox"
Email.Subject = "subject"
Email.Textbody = ss&date ()'ss is the obtained ip
The path to the 'Email.AddAttachment "attachment for example: C:\ foo.zip"
With Email.Configuration.Fields
.Item (NameSpace& "sendusing") = 2
.Item (NameSpace& "smtpserver") = "smtp.163.com" 'smtp server address
.Item (NameSpace& "smtpserverport") = 25
.Item (NameSpace& "smtpauthenticate") = 1
.Item (NameSpace& "sendusername") = "account name, sending mailbox"
.Item (NameSpace& "sendpassword") = "password"
.Update
End With
Email.Send
Note the parameter settings in the code.
The above is all the contents of the article "how to use vbs to get a public network IP and send it to a specified mailbox". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!