65.9K
CodeProject is changing. Read more.
Home

WAN/Internet IP Emailer Using a GMail Account

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.25/5 (6 votes)

Aug 24, 2008

CPOL

2 min read

viewsIcon

27215

downloadIcon

677

Obtains a new WAN/Internet IP and sends it to a specified email address using a GMail account.

Introduction

This code checks for internet connectivity, and if internet is available, it obtains the Wan/Internet IP address and sends this IP address to a specified email address using a GMail account.

This application is useful for users who want to control their PCs remotely and their Wan IP address is dynamic. I wanted to control the uTorrent software running on my computer. The problem was that my internet IP address was dynamic and in order to control this software, you need to have the current internet IP address. This application solves this problem by sending me an email containing the latest internet IP address. Now, I can control my software from anywhere.

Using the application

In order to use the application, you must have a GMail account for sending emails to a desired address, and its POP settings should be enabled. Another account can be used, but then you will have to change the SMTP settings in the code. This application is dependent on .NET framework 2.0, so it must be installed on the system.

This application can be selected to run at Windows startup. You can specify the time, 1-60 min, for auto checking the IP, and if there are changes in the WAN IP, then it will send the email. If you want to log the IP addresses, then you can specify a log file. Each new IP address will be appended to the log file.

Note: When this application starts, it goes to the system tray. You have to double click the system tray icon to view the interface of the application.

Code explanation

IsInternetAvailable() checks for the internet connectivity by getting the Google host entry. If this is obtained, then internet is available. GetWanIP() obtains the WAN IP from "http://www.whatismyip.com/automation/n09230945.asp". EmailWanIP(String ip) sends the email with the IP address in the body of the mail.

ProcessWanIP() calls the above three functions and checks whether an email has been sent since the new WAN IP. The email is sent only once when the WAN IP is changes. This function is called by the timer used in the application.

History

  • Version 1.0.