C# Windows Service for sending text messages (SMS) from a cell phone

Last year we (the TeaBreak team) thought of holding a Hi-Tea event for bloggers in Pakistan. We agreed that it would a nice idea to ask bloggers RSVP online so that we can keep things in order. The event went good but the good part was also an SMS-based RSVP system!

A couple of hours of coding and I came up with a small script that would take a person’s name, email and mobile number. The script will later send an SMS containing a unique ticket number. The ticket number served as an entry pass as we had limited seats for the event. Those who signed up for RSVP got a tid bit surprised with SMS mechanism, although I thought it to be quite primitive.

Here’s the C# Windows Service that was running on my computer back then that was sending all the SMSes to folks. The service would connect to a MySQL database on my hosted server and fetch any pending messages (SMSes) that were to be sent. I hooked up my old Samsung phone with a serial data cable to my computer.

I thought to share it here just in case if anybody is looking for enjoying some kind of SMS feature in their applications.

Click here to download the C# code

(I am only uploading the class file rather then the complete VS project – SMSController.cs – you can build it in a windows service or whatever you prefer)

Pointers on how SMS sending and receiving works:

  1. You connect a GSM modem or a mobile phone to your computer which appears as a communication port (COM1, COM2, etc.)
  2. You send extended “AT” commands to the COM port to communicate
  3. Here’s a tutorial on the “AT” commands for GSM modems/phones:
    http://www.developershome.com/sms/atCommandsIntro.asp

This is just a very basic class, if you need help on multimedia messages (MMS) support, or come across some issues etc. you can get in touch with me.

 

This entry was posted in Experiments, Old Ramblings and tagged , , , , , . Bookmark the permalink.