Click here to Skip to main content
Click here to Skip to main content
Go to top AT commands to send SMS

, 25 Mar 2009
Rate this:
Please Sign up or sign in to vote.
this article allows you to send SMS to any mobile using GSM modem or your mobile connected via USB able to Computer


This code provided allows to send SMS from the PC to any mobile with the help of GSM modem or any GSM compatible mobile.


Basically I am making use of AT commands , which are AtTention Commands which are used for  communication between the computer and the modem.

Microsoft windows provides witha software called Hyperterminal which is available through thispath.

Start-> Programs-> Accessories->communications->hypertreminal

AT commands can be typed here. Hypertreminal communicates directly with the modem /mobile connected and instructs the modem. It also gives responses back as OK or error etc. But if we have a application where we need to send SMS after a specific set of actions, then hypertreminal is not useful, since it requiers manual typing. You need to select the COm port on which modem/mobile is connected.(port can be serial port for modem or USB port for mobile).

The code given does this.If any doubs are there you can contact me on the forum below

Using the Code

First, connect modem or mobile. Go to device manager and under Ports options check for which COM (e.g. COM3 , COM4 etc)port your modem/mobile has been connected to.

// if COM3 is shown in device manager then put COM4 in foll statement
    Dim SMSEngine As New SMSCOMMS("COM4")

'the port needs to be initialised

SMSPort = New SerialPort
        With SMSPort
            .PortName = COMMPORT
            .BaudRate = 19200
            .Parity = Parity.None
            .DataBits = 8
            .StopBits = StopBits.One
            .Handshake = Handshake.RequestToSend
            .DtrEnable = True
            .RtsEnable = True
            .NewLine = vbCrLf
        End With 

        'this is  the set of AT commands to be written on serial port

            'set command message format to text mode(1)
            SMSPort.WriteLine("AT+CMGF=1" & vbCrLf) 
            'set service center address (which varies for service providers (idea, airtel))
            SMSPort.WriteLine("AT+CSCA=""+919822078000""" & vbCrLf)             
            ' enter the mobile number whom you want to send the SMS
            SMSPort.WriteLine("AT+CMGS=  + TextBox1.text + " & vbCrLf) 
            _ContSMS = False
            SMSPort.WriteLine("+ TextBox1.text +" & vbCrLf & Chr(26)) 'SMS sending

    Dim i As Integer
    Private Sub Button1_Click(ByVal sender As System.Object,
       ByVal e As System.EventArgs) Handles Button1.Click

        SMSEngine.Open() 'open the port
        SMSEngine.SendSMS() 'send the SMS

    End Sub

class SMSCOMMS is defined in the code. I have tried this code with only nokia mobiles like nokia 5310, nokia 3500 etc. ALso i have tried sending sms from airtel provider to idea also. It works fine. Download the code. Its simple n explained with comments. 

Points of Interest

Programming in mobile communication, serial port interfacing, TAPI programming


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

namrata khandeparkar
Software Developer (Junior)
India India
hello . I am studying BE in information technology in GOA.
My interests lie in programming in mobile communication in etc.

Comments and Discussions

QuestionSolved Pinmemberniranjanbhuta200612-May-14 1:24 
Questionnot working in samsung galaxy s4 PinmemberMember 106445546-Mar-14 1:42 
Questionnokia c2-02 & nokia 2700 classic PinmemberMember 806042015-Dec-13 3:13 
Questionhow i can send sms in Pingroupirfanansari21-Sep-13 1:57 
Question.PortName = COMMPORT Pingroupirfanansari30-Aug-13 23:13 
QuestionMy Application freezes PinmemberKashif Alvi25-Aug-13 5:21 
QuestionIt work, but change something Pinmembersennetwork20-Jun-13 21:35 
GeneralMy vote of 5 Pinmembermohajery6-Jun-13 7:56 
BugMy phone is restarting.. Pinmemberngagebhavik12-Apr-13 22:51 
QuestionNot Working.. Pingroupbandhalaraja31-Jan-13 18:33 
AnswerRe: Not Working.. Pinmembersennetwork20-Jun-13 21:36 
QuestionTimeoutException was unhandled PinmemberArthurWong8923-Jan-13 4:40 
GeneralMessage center number PinmemberDibu.net3-Jan-13 1:57 
GeneralMy vote of 4 Pinmembersaqibsabir25-Dec-12 18:45 
QuestionNot Sending Help Please Pinmembersaqibsabir25-Dec-12 7:53 
QuestionPORT ERROR. PinmemberAnz Tara18-Dec-12 20:42 
Questionnot sending Pinmemberagung.imannuel2-Oct-12 1:42 
AnswerRe: not sending Pinmemberagung.imannuel2-Oct-12 3:09 
QuestionNot sending Pinmembersatinderhundal1983@gmail.com24-Aug-12 6:12 
Questionbad download PinmemberWenerLove18-Aug-12 12:22 
QuestionEverything works fine without Service Center Number PinmemberMember 85651184-Jun-12 23:24 
AnswerRe: Everything works fine without Service Center Number Pinmemberagung.imannuel2-Oct-12 3:20 
Questionyour code is not working with windows mobile PinmemberMu Shahid25-May-12 23:16 
QuestionHeloo Pinmembersyahmi.rusli17-May-12 7:28 
QuestionRececiving ??? in my message PinmemberAmish Jariwala18-Apr-12 20:02 
Questiondoes not work on samsung mobile PinmemberMember 87098117-Mar-12 17:59 AT commands to send SMS Pinmembersmp from pune27-Feb-12 1:28 
QuestionDoes not work on Samsung Mobile PinmemberPatil Kishor13-Feb-12 0:27 
AnswerRe: Does not work on Samsung Mobile Pinmembershivayogirk14-Feb-12 23:03 
Questionsms in Pinmemberchimwemwe sinkamba30-Aug-11 2:50 
Questionproblem with this code PinmemberMember 790719225-Aug-11 1:48 
QuestionDoes NOT work PinmemberOnur Guzel19-Jul-11 2:40 
GeneralMy vote of 5 PinmemberRajiv nayan5-Jul-11 1:37 
Generalnokia3110 classic Pinmemberpkumar00929-May-11 1:51 
Generalproblem with coding Pinmemberpadmavath24-May-11 20:32 
QuestionWin7 and ports PinmemberNi8max23-May-11 4:07 
GeneralPORT IN USE ERROR PinmemberIgnatius Maziofa18-May-11 2:45 
GeneralMobile Broadband PinmemberMember 777059920-Mar-11 17:25 
Questionreceiver never receives the msg Pinmemberbasheer.j12-Mar-11 16:47 
AnswerRe: receiver never receives the msg PinmemberMarko Joksimovic8-May-11 15:01 
AnswerRe: receiver never receives the msg PinmemberMember 790719228-Aug-11 20:25 
Questionneed help to send sms through c# application Pinmemberhema1217-Feb-11 0:09 
Generalgsm modem project Pinmemberselcuk bekmezci4-Jan-11 11:50 
Generalcode is not working please help me PinmemberS.P.GUPTA10-Nov-10 4:18 
GeneralMy vote of 5 PinmemberHeaven20203-Nov-10 9:48 
GeneralMy vote of 5 Pinmemberasghar200831-Oct-10 7:44 
GeneralHelp for Project PinmemberBy.W23-Oct-10 4:31 
GeneralRe: Help for Project PinmemberOrhan Albay26-Oct-10 9:39 
Generalproblem - no message is sent PinmemberDimitar_J24-Sep-10 0:48 
GeneralList of Ports Pinmemberjarsenal16-Sep-10 13:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140926.1 | Last Updated 25 Mar 2009
Article Copyright 2009 by namrata khandeparkar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid