Obtain the Internet IP address and send the vbs code to the specified mailbox [tested]

Source: Internet
Author: User

CopyCode 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 email"
Email. To = "receive email"
Email. Subject = "topic"
Email. textbody = SS & date () 'ss is the obtained IP Address
'Email. addattachment "the attachment path is: 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, email sending"
. Item (namespace & "sendpassword") = "password"
. Update
End
Email. Send

Pay attention to the parameter settings in the code.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.