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…

Follow me on Twitter   RSS feed   Donate

This entry was posted in miscellany and tagged , , , , , . Bookmark the permalink.

2 Responses to Anatomy of an example

  1. Niyazi says:

    using System;
    using System.Collections; //.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using WMPLib;

    namespace MediaPlayer
    public partial class WMPlayer : Form
    public WMPlayer()

    private void openItem_Click(object sender, EventArgs e)

    player.FileName = openMediaFileDialog.FileName;

    // adjust the size of the Media Player control and
    // the Form according to the size of the image
    player.Size = new Size(player.ImageSourceWidth, player.ImageSourceHeight);

    this.Size = new Size(player.Size.Width + 20, player.Size.Height + 60);

    } // end method openItem_Click

    // Exit menu Item
    private void exitItem_Click(object sender, EventArgs e)

    private void aboutMessageItem_Click(object sender, EventArgs e)

    I am write code in VS 2010. I have problem with Windows Media Player’s Property FileName. As You can see above I have named WMpler as Player. I am writing “player.FileName” seems error and
    player.Size = new Size(player.ImageSourceWidth, player.ImageSourceHeight);
    Please Help Me
    Best Regards

  2. Pingback: Extract part of a JSON file in C# - C# HelperC# Helper

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.