How to get my public IP by using VBScript

Posted on 2004-08-23
Last Modified: 2010-05-02
Dear sir,

  I would like to do the following:

  Write a script / program to get the public IP address that I'm using
  Send this IP address by using SMTP to specific e-mail address

  It will be great if you can provide a full sample code.  Thank you very much.


Question by:towo2002
  • 2
LVL 36

Expert Comment

ID: 11877994

I'm not sure if this is possible with VBScript although it is with server-side includes:

<!--#echo var="REMOTE_ADDR"-->

LVL 36

Expert Comment

ID: 11877997
As for the sample code, I'm not too familiar with VBScript, but you'd probably Dim a variable to equal <!--#echo var="REMOTE_ADDR"--> and then send the mail (which I'm not sure how to do unfortunately)

LVL 53

Accepted Solution

Dhaest earned 125 total points
ID: 11880184

Assisted Solution

steve92122 earned 125 total points
ID: 11880245

I just tried this and it works fine. I remember i had problems before with permission setting up CDO.mail. I put this script in an asp page and when the page loaded i recieved a mail containing my IP address almost instantly.

set objMail = CreateObject("CDO.Message")
objMail.To = <your e-mail address>
objMail.From = <your e-mail address>

'set up the mail configuration information
objMail.Configuration.Fields.Item("") = 2
objMail.Configuration.Fields.Item("") = <smtp server>
objMail.Configuration.Fields.Item("") = 25

'message details
objMail.Subject = "My Ip Address"
objMail.HTMLBody  = Request.ServerVariables("REMOTE_ADDR")

'send the mail

'display confirmation or an error message to the asp page
if Err.number = 0 then
      Response.Write "Sent Mail<hr>"
      Response.Write err.number & ";" & err.Description
end if
set objMail = nothing

Hope this helps,


Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb6 connector to SQL Server 2 37
MsgBox 4 59
Problem to With line 4 57
VBA: copy range dynamically based on config sheet v2 3 33
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question