C#.net

Make SMS Gateway using C#.net



box_sms_gateway.jpg   Hi friends…I have been into this SMS gate way stuff some 6 months back.My requirement was to send and receive sms using a mobile phone connected to my computer via bluetooth using a C#.net application.When i googled for it i got to know that there are many SMS gateway softwares available and obviosuly none of them are free…I used many sms gateways like OZEKI ,Mcore etc. …But the problem is all of them are paid softwares and so it does have limitations. So i tried making an sms gateway of my own and by gods grace i succeded.

Here is the source code

I used Serial port communication using c#.net and AT commands for communicating with the modem. ..Its working perfectly for me.I can send and receive sms using this … You can download ,distribute and modify this code to meet your requirements. If u prefer using OZeki(SMS Gateway software) ,here is the tutorial for using those kind of stuffs

http://www.shefeekj.com/send-sms-fro…ql-server.html

 

Before reading this tutorial,you may consider reading my previous articles

At-commands and serial port communication

 

I will sum up the method which i have implemented

Send SMS

1.Take message from User

2.Convert it to PDU format

3.Connect the mobile using the serial port.

4.Send the message in Pdu format to the mobile using AT Commands(Read previous article about AT COmmands)

Receive SMS

1.Connect the mobile using the serial port.

2.Read SMS from mobile using AT COmmands(Read previous article about AT COmmands)

3.Extract the message from PDU format

The process of reading sms from mobile do have limitations.Nokia phones normally does not allow to read its phone memory due to security reasons.So it workks only with Sony Erricson handsets.

Okiee..lets move on to the source code..It contains mainly 3 classes

1.SMSCOMMS.cs

This class is responsible for sending and receiving sms.Separate functions are written inside this class to send,receive and to estab ish connection before sending.

2.SendSms.cs

This class converts the message in text format to pdu format which can be recognised by mobiles.If you want to know what exactly is pdu format,you may consider reading my previous article

3.ReceiveSms.cs

This class extracts message from PDU format into human readable text format.

How to use this class?

Hope you know the port in which you connected your mobile.Please change the port specified in the class SMSCOMMS.cs

You can invoke these classes in the following format

SendSMS obj = new SendSMS();

obj.SendSms(“MessageBody”,”919995724121″);

You can Receive SMS in the following format

ReceiveSMS obj = new ReceiveSMS();

obj.Receive();
The reccieved message will be avalable in the array messageDetails[]

messageDetails[0] = Message Centre Number
messageDetails[1] = Sender Number
messageDetails[2] = Message

Please comment on  if you the code is not working for you or incase you need more clarifications

Share

Thanks for reading my blog. If you like what I write, why not subscribe to my feed?

If you are busy, I can send the latest post to your email. Just subscribe to my email updates.

 

Enter your email address:

Delivered by FeedBurner

Discussion

10 comments for “Make SMS Gateway using C#.net”

  1. Great!
    I’ll look for any old phone and connect it to my computer using Bluetooth, and try this out.

    Thank you!

    Posted by Stefan | August 5, 2009, 4:47 am
  2. Nice.
    I’m having doubt.Without using Gateway and GSM i want to simulate send and receive sms application(Monitoring application).I want to implement these features in C# with oops concepts.Could you please help me and give any source codes.

    Posted by Maha | August 25, 2009, 1:38 am
  3. nice .
    very good work but i was looking for auto detecting new sms may you help me??

    Posted by Sukhjot | September 8, 2009, 11:04 am
  4. Nice work :D can u use this to send sms or mms to a website, like twitter function, I wanna sms like ( I am dancing all drunk at Movida in london) to a what Am i doing right now site

    is this in anyway possible???

    Thx Andreas

    Posted by Andreas | November 29, 2009, 11:20 am
  5. Looks great, but my knowledge in this is poor. Could I ask You too please provide the code for a simple demo?

    Erik

    Posted by erik | January 4, 2010, 10:45 am
  6. Can u assist me in building up the web service.
    I am having some problem in combining your code to my website.

    Regards
    Rishidevdas

    Posted by rishi | February 5, 2010, 10:34 pm
  7. can u plz mention the phone u used
    for connecting…..
    can i connect my mobile using data cable….
    thanks…

    Posted by arun | February 15, 2010, 5:18 am
  8. excellent work!!!!!!

    i will try out this code.

    what exactly do v need to change code other then COM PORT NUMBER and MESSAGE CENTER NUMBER.

    Posted by raj | March 5, 2010, 4:41 pm
  9. Thanks a lot

    Posted by Nitin | March 6, 2010, 10:27 pm

Post a comment