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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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)


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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 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