Title: Anatomy of an example
Usually I have to think of example ideas myself, but sometimes someone asks me a question that leads to an interesting post. Occasionally the original question leads to a new idea, which leads to another idea, and so on.
This time I thought I would write an example that sends a SMS (Short Message Service) text message. I knew that you could do that by sending an email to the appropriate address. That lead to two threads of research: sending an email (which is a bit of a hassle) and finding the format of the necessary email address.
The email address depends on the intended recipient's phone number and carrier, so I went online to try to find a list of the carriers' SMS gateway email addresses. Wikipedia has a decent list but it's in the form of a table that would require a lot of manual retyping to use. Eventually I found a much better list at:
That gateway list is updated reasonably frequently (as I write this, the last update was two months ago), so that lead to a new topic: how to download the latest version of a file whenever a program starts.
The gateway file is also stored in JSON (JavaScript object notation) format so that lead to the final topic for this example: JSON. Or actually the final two topics. JSON is a data storage format with a purpose similar to that of XML (eXtensible Markup Language). One of the easier ways to use either XML or JSON is to serialize and deserialize objects. So that's the first topic: how to use JSON to serialize and deserialize objects.
Unfortunately the SMS gateway file contains a fairly long and complicated pile of data and the file's web site doesn't provide a definition for a class into which a program could deserialize the data. That leads to the final (really) topic in the series: how to read JSON data when you don't really understand or care about all of the data.
So from this one idea, to send an SMS message, came the following topics:
- How to download a text file each time a program runs in C#
- How to use JSON to serialize and deserialize objects in C#
- How to extract only some of the information from a JSON file in C#
- How to send an email message in C#
- How to send an SMS text message in C#
So I'll be posting these examples in the next several days. The holidays may slow things down so it could take a while. Stay tuned...
Download the example to experiment with it and to see additional details.
|