Solved

How to get my public IP by using VBScript

Posted on 2004-08-23
7
659 Views
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.

Regards,
Towo2002

0
Comment
Question by:towo2002
  • 2
7 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11877994
Hi

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

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

Regards,
Zyloch
0
 
LVL 36

Expert Comment

by:Zyloch
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)

Regards
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 125 total points
ID: 11880184
0
 
LVL 1

Assisted Solution

by:steve92122
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("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = <smtp server>
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMail.Configuration.Fields.update

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

'send the mail
objMail.Send

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


Hope this helps,

Steve
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now