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.

 

Be Sociable, Share!
    This entry was posted in Experiments, Old Ramblings and tagged , , , , , . Bookmark the permalink.

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

    1. Rakesh says:

      Cool post Sim. Will try this one out.

    2. Asim says:

      Thanks man 🙂

    3. ijlal says:

      very nice and useful sharing. thanks alot.

    4. Asim says:

      Welcome and Thanks, Ijlal.

    5. Faheem says:

      Hello,
      I like ur post and it is very relevent to the problem i m having. i just need another function to recieve an sms. i ll be thankful if u coulg help me out
      Regards,
      Faheem.

    6. shehar bano says:

      your post is very useful-i am developing a website which has a feature of allowing subscribers to send sms-in real world, better approach would be to purchase bulk messaging services of a telecom company or use third party web services-but because thsi is a semester project and more focussed on MY INPUT, so i am using my phone as modem and sending AT commands to it-
      the PROBLEM:
      sometimes a message might not be successfully sent due to some issue-i want to keep record of messages that were actually sent and those which were not sent (because UFone notified me)- how can i detect messages that were not really sent?

      and thanks for reading my loong rant…although i have very faint hope of receiving a reply :p

    7. Deven says:

      with all due to respect sir/mam
      i would olike to inform you above link are all
      usless.
      FeedBack:-close it perticuler.Thanking You

    8. Kumar Satyendra says:

      hi sir/madam,
      this code is very useful to me, actually im very new regarding window services, actually i want a service which can send message in bulk automatically in particular condition like if intime is greater than 10 am or out time is less than 6 pm. all these stuff i did in window application and its workin fine, but for dat i have to open my application again and again and have to click send msg button.
      but i want all these thing automatically…
      so if u have any solution regarding dis problem please guide me via my mail satyam1849@gmail.com
      Thanks & regards

    9. Waqas says:

      hi,
      nice post ….
      Can you send me the complete project…
      my email id is:
      m.waqas08@yahoo.com

    10. Salman says:

      Hi Asim!
      this is very nice project can you send this complete project on my mail address
      salmaan.nicon@gmail.com

    Leave a Reply

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