Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbs to get a public network IP and send it to a specified mailbox

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report