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.
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.