My Digital Story

Just to make live easier…

Send your latest computer dynamic IP to email

I was away from my office PC last week when my Outlook email account reached 60 MB (ONLY).  So I no longer can receive or send any new mail from my Windows Mobile phone. Luckily Gmail is always there to save the day.

As usual, I logged in my PC into my company’s Workforce Portal (a generic name would be Virtual Private Network) which is using Juniper Network Connect. Through Workforce Portal we are virtually inside the office.

My intention was to remote into my office PC so that I could archive all the old mails ( Yes, my fault also for not using auto archive).  I launched the mstsc.exe (Remote Desktop Connection) at the Run/Start Menu and just clicked the connect on the IP address already shown there.  And then the nightmare came…It was no longer my IP address! I could not connect!

Not again…My office computer’s IP address was flushed again by the DHCP server!

So, after I start to find a solution on how can I keep myself update to the computer dynamic IP address which so that whenever I want to use the Remote Desktop, I will always know the current IP address.

I tried to find dedicated applications in the Internet for that, e.g IP Watcher, Dynamic IP Monitor but those are just not working as intended. The IP Watcher only email the external public IP (My company WAN IP address, or the Internet IP address).,while the Dynamic IP Monitor for whatever reasons give my internal IP address as 0.0.0.0 which is non-sense.

Out of desperation, I need to have my own solution.

IP address will only dynamically change when the PC start, so if I could make a MS-DOS command line script so that  at each boot,  the computer will send email containg its latest IP address to my Gmail account.

To accomplish that, I need to have an application that can send email with attachment from command line. To do that, all I need is this little piece of applicate, called SendEmail.

Download the file and extract it to your C: drive.
Open Notepad, write the following code:

ipconfig >C:\ipaddress.txt
SendEmail.exe -f FROMADRESS -t TOADDRESS -u SUBJECT -m MESSAGE -s SMTPSERVER -a C:\ipaddress.txt

Save the file as filename.bat maybe at C:\

Create this file shortcut in your Start Menu/Startup so that this script will launch each time when your PC boots.

The first command (ipconfig >C:\ipaddress.txt) is actually to copy your IP configuration into a file called ipaddress.txt in yout C:\

The next command is to send this attachment to your email using the SMTP server. So make sure you know the SMTP server IP address of its DNS name.

So, now each time my computer boot with a new IP address, I will have its IP address in my Gmail account. Now I can use the Remote Desktop from anywhere without worrying on the dynamic IP address anymore.

16/01/2009 - Posted by | Windows XP troubleshootings | , , , ,

11 Comments »

  1. good god your solution is the EXACT one i needed man .. tks
    let me know if u have any interesting CLI scripts or techniqs or even programs in future ^^

    Comment by Henry | 13/02/2009

  2. Hi, is it possible to create a script to check my ip address every X minutes and send it to my email? Thanks

    Comment by oldSAP | 07/03/2009

  3. Thx for the script and idea’s i will use them and add some.

    Comment by Mikael | 26/05/2009

  4. Assalamualaikum,

    Terimakasih… my wife’s office block my home network IP camera using websense. The only way to do it is to use ip adress. This is what I am looking for.. thanks man..

    Comment by Amin | 15/06/2009

  5. Hello This didn’t work for me. I download the sendmail file on my c drive C:\sendmail> but can’t run the sendmail Pl file. I created the filename.bat file and configure it to my info but i think something is missing. Can i get a walk through?

    Comment by Pepie | 20/09/2009

  6. They recorded three separate versions of the single; the one recorded on X&Y was based on an early cut of the song. ,

    Comment by Loy31 | 11/10/2009

  7. I took your idea to the next step. I study in a different town which is around 100 km away so i go home for weekends but I don’t carry my laptop with me everytime(no big needs), but from time to time I have to. So i deciced to make me a rdp connection.
    But where I live, we have a router which is connecting to the internet and my ISP flushes dynamic IPs god knows when so I have to know my external IP every so often.

    So I’ve done a little googleing and found put about this program, curl(http://curl.haxx.se/), which is used to print source from websites. So I took this program and have it look up http://www.whatismyip.com and save it in a file the same way you did it.
    The next steps are pretty much the same as yours with ipconfig and sendEmail set up to gmail.

    One more thing I did was to get another program called hstart which starts bat files hidden(no console opens). So I took all of this and embeded it in task manager which is set to go of every hour… so now i get my IP sent to me every hour indefinitely

    Comment by Kristjan Petelin | 17/01/2010

  8. Sorry the webpage is http://www.whatismyip.org.

    Comment by Kristjan Petelin | 17/01/2010

  9. I’ve had the same problem, but I noticed an interesting thing in gmail, if you leave your account open at another location there is a message at the bottom of the page that says: “This account is open in 1 other location (….) and gives an IP address where the account is open. If you always had gmail logged in on the computer you wanted to remote into then where ever you are you can log into gmail and see what the IP address is. I haven’t tried this yet, I will tonight.

    Comment by Ryan | 19/05/2010

  10. Hello, what if you are behind a router? how can you get the wan IP

    Comment by Ahmed | 21/05/2010

  11. The download link is the pls help I need this

    Comment by Olaru | 23/05/2011


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: