Click here to Skip to main content
15,896,118 members
Articles / Programming Languages / C#

WAN/Internet IP Emailer Using a GMail Account

Rate me:
Please Sign up or sign in to vote.
2.25/5 (6 votes)
23 Aug 2008CPOL2 min read 27K   677   20   3
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Streaming Networks
Pakistan Pakistan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
MO15ON1-Oct-09 21:54
MO15ON1-Oct-09 21:54 
AnswerAlternative: Dynamic DNS Pin
x-cubed24-Aug-08 15:48
x-cubed24-Aug-08 15:48 
GeneralRe: Alternative: Dynamic DNS Pin
harissarwar25-Aug-08 22:38
harissarwar25-Aug-08 22:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.