Send external IP address to an email

0

I want to remotely send the IP address (external) of a desktop PC when it changes. I found this page explaining how to build a Windows service doing exactly what I was looking for:

  • Run every 30 minutes, checking for IP address changes.

  • Send the new address to an email.

The code they give was split into three parts but I don't know if I just need to copy the three pieces of code together or how to build the code. The final thing is there is no mention of how to authenticate an SMTP account -- where do I need to put the credentials?

I don't know programming, thank you for your help.

P. Kod

Posted 2018-03-26T12:37:00.853

Reputation: 43

Answers

2

The code they give was split into three parts but I don't know if I just need to copy the three pieces of code together or how to build the code.

Based on the final code given in the associated .zip file link, it appears some of the code blocks are meant to be used in separate files. The language is C# and the code was intended to be built with Microsoft Visual Studio 2013 (according to the tags in the project page side-bar).

There is no mention of how to authenticate an SMTP account -- where do I need to put the credentials?

Apparently, the program has a configuration file that you can put this data into.

At a guess, this seems to be App.config in the main .zip folder... however, since this file is copied twice when built (as ExternalIPChecker.exe.config and ExternalIPChecker.vshost.exe.config), I honestly can't say for certain where you would want to put these.

As a thought, I would probably make a copy of App.config (for backup purposes) and then change it in the original file (it has other settings that seem important as well).


Building ExternalIPChecker (Overview)

  1. Download and install a copy of Microsoft Visual Studio. You want the free "Community" edition (the web installer is currently available from the Community option under the Visual Studio IDE/Download For Windows link). The web installer itself is approximately 1.1MB and labeled vs_Community.exe.

  2. After installing Visual Studio, download and unzip the ExternalIPChecker.zip file from the project page you gave initially (it is the first link at the top, under the Introduction).

  3. Open the ExternalIPChecker.csproj file in your extracted .zip folder with Visual Studio (this should be as simple as double-clicking the file). Visual Studio should open with the ExternalIPChecker project loaded.

  4. It seems as though this project relies on Apache log4net and the project itself comes with an outdated version. Since log4net is distributed as a NuGet package, I was able to update to the most recent version by opening ProjectManage NuGet Packages... in Visual Studio and clicking the blue Upgrade arrow next to the log4net entry in the main NuGet window .

  5. I rebuilt the Solution at this point and I would suggest you do this as well (BuildRebuild Solution).

  6. Lastly, I ran BuildBuild ExternalIPChecker which created the final files for ExternalIPChecker. Based on my settings and the project page instructions, these were created in the bin\Release folder of the original extracted .zip file directory.

Installation instructions are given under the How To Install? section of the project page.


Note that Visual Studio can be extremely large. I would suggest at least 20GB free to download and install it using the web installer in Step 1, above.


Anaksunaman

Posted 2018-03-26T12:37:00.853

Reputation: 9 278

I learned a lot from your detailed answer, i understand now how i can work with that code you made it appear easy to me. I had in the past a basic understanding of C language and i think with a bit of effort i can follow your instructions to build a C# project. In this moment i don't want to install Visual Studio but i want to ask you if i can implement a similar code using C language, i have CodeBlocks installed. I built and run a C code that get the external IP successfully but i'm struggling currently to to send an email, i tested lot of codes using curl library but are not working. – P. Kod – 2018-03-28T13:59:57.090

I tried This code, when i run it it says it connects to google server but it gives me error saying * error setting certificate verify locations CAfile: /path/to/certificate.pem CApath: none.

– P. Kod – 2018-03-28T14:04:47.070

1

It sounds like you're actually looking for a dynamic DNS service so you retain the ability to connect to your home network even when your router's public IP changes.

There are many to choose from, and almost all have a Windows client available for download.

Alex

Posted 2018-03-26T12:37:00.853

Reputation: 2 094

I have tried some of these but lot of adds and they don't work well, sometimes cruching and need to configure every reboot. What i want is that program. Can you tell me what language is that ? – P. Kod – 2018-03-27T11:19:51.063

If you need to configure it at every reboot, something is wrong. Which ones have you tried, exactly? – Alex – 2018-03-27T11:38:45.927