Click here to Skip to main content
11,412,526 members (72,884 online)
Click here to Skip to main content AT commands to send SMS

, 25 Mar 2009 CPOL
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

QuestionSmall project for Namrata (sms component) Pin
Member 11640868 at 24-Apr-15 23:26
memberMember 1164086824-Apr-15 23:26 
QuestionI want same code in VB6. Can you give me ? Pin
Rahul Kanchan at 17-Mar-15 18:13
memberRahul Kanchan17-Mar-15 18:13 
QuestionSolved Pin
niranjanbhuta2006 at 12-May-14 2:24
memberniranjanbhuta200612-May-14 2:24 
Questionnot working in samsung galaxy s4 Pin
Member 10644554 at 6-Mar-14 2:42
memberMember 106445546-Mar-14 2:42 
Questionnokia c2-02 & nokia 2700 classic Pin
Member 8060420 at 15-Dec-13 4:13
memberMember 806042015-Dec-13 4:13 
Questionhow i can send sms in Pin
irfanansari at 21-Sep-13 2:57
groupirfanansari21-Sep-13 2:57 
Question.PortName = COMMPORT Pin
irfanansari at 31-Aug-13 0:13
groupirfanansari31-Aug-13 0:13 
QuestionMy Application freezes Pin
Kashif Alvi at 25-Aug-13 6:21
memberKashif Alvi25-Aug-13 6:21 
QuestionIt work, but change something Pin
sennetwork at 20-Jun-13 22:35
membersennetwork20-Jun-13 22:35 
GeneralMy vote of 5 Pin
mohajery at 6-Jun-13 8:56
membermohajery6-Jun-13 8:56 
BugMy phone is restarting.. Pin
ngagebhavik at 12-Apr-13 23:51
memberngagebhavik12-Apr-13 23:51 
QuestionNot Working.. Pin
bandhalaraja at 31-Jan-13 19:33
groupbandhalaraja31-Jan-13 19:33 
AnswerRe: Not Working.. Pin
sennetwork at 20-Jun-13 22:36
membersennetwork20-Jun-13 22:36 
QuestionTimeoutException was unhandled Pin
ArthurWong89 at 23-Jan-13 5:40
memberArthurWong8923-Jan-13 5:40 
GeneralMessage center number Pin at 3-Jan-13 2:57
memberDibu.net3-Jan-13 2:57 
GeneralMy vote of 4 Pin
saqibsabir at 25-Dec-12 19:45
membersaqibsabir25-Dec-12 19:45 
QuestionNot Sending Help Please Pin
saqibsabir at 25-Dec-12 8:53
membersaqibsabir25-Dec-12 8:53 
QuestionPORT ERROR. Pin
Anz Tara at 18-Dec-12 21:42
memberAnz Tara18-Dec-12 21:42 
Questionnot sending Pin
agung.imannuel at 2-Oct-12 2:42
memberagung.imannuel2-Oct-12 2:42 
AnswerRe: not sending Pin
agung.imannuel at 2-Oct-12 4:09
memberagung.imannuel2-Oct-12 4:09 
QuestionNot sending Pin at 24-Aug-12 7:12
membersatinderhundal1983@gmail.com24-Aug-12 7:12 
Questionbad download Pin
WenerLove at 18-Aug-12 13:22
memberWenerLove18-Aug-12 13:22 
QuestionEverything works fine without Service Center Number Pin
Member 8565118 at 5-Jun-12 0:24
memberMember 85651185-Jun-12 0:24 
AnswerRe: Everything works fine without Service Center Number Pin
agung.imannuel at 2-Oct-12 4:20
memberagung.imannuel2-Oct-12 4:20 
Questionyour code is not working with windows mobile Pin
Mu Shahid at 26-May-12 0:16
memberMu Shahid26-May-12 0:16 
QuestionHeloo Pin
syahmi.rusli at 17-May-12 8:28
membersyahmi.rusli17-May-12 8:28 
QuestionRececiving ??? in my message Pin
Amish Jariwala at 18-Apr-12 21:02
memberAmish Jariwala18-Apr-12 21:02 
Questiondoes not work on samsung mobile Pin
Member 8709811 at 7-Mar-12 18:59
memberMember 87098117-Mar-12 18:59 AT commands to send SMS Pin
smp from pune at 27-Feb-12 2:28
membersmp from pune27-Feb-12 2:28 
QuestionDoes not work on Samsung Mobile Pin
Patil Kishor at 13-Feb-12 1:27
memberPatil Kishor13-Feb-12 1:27 
AnswerRe: Does not work on Samsung Mobile Pin
shivayogirk at 15-Feb-12 0:03
membershivayogirk15-Feb-12 0:03 
Questionsms in Pin
chimwemwe sinkamba at 30-Aug-11 3:50
memberchimwemwe sinkamba30-Aug-11 3:50 
Questionproblem with this code Pin
Member 7907192 at 25-Aug-11 2:48
memberMember 790719225-Aug-11 2:48 
QuestionDoes NOT work Pin
Onur Guzel at 19-Jul-11 3:40
memberOnur Guzel19-Jul-11 3:40 
GeneralMy vote of 5 Pin
Rajiv nayan at 5-Jul-11 2:37
memberRajiv nayan5-Jul-11 2:37 
Generalnokia3110 classic Pin
pkumar009 at 29-May-11 2:51
memberpkumar00929-May-11 2:51 
Generalproblem with coding Pin
padmavath at 24-May-11 21:32
memberpadmavath24-May-11 21:32 
QuestionWin7 and ports Pin
Ni8max at 23-May-11 5:07
memberNi8max23-May-11 5:07 
Ignatius Maziofa at 18-May-11 3:45
memberIgnatius Maziofa18-May-11 3:45 
GeneralMobile Broadband Pin
Member 7770599 at 20-Mar-11 18:25
memberMember 777059920-Mar-11 18:25 
Questionreceiver never receives the msg Pin
basheer.j at 12-Mar-11 17:47
memberbasheer.j12-Mar-11 17:47 
AnswerRe: receiver never receives the msg Pin
Marko Joksimovic at 8-May-11 16:01
memberMarko Joksimovic8-May-11 16:01 
AnswerRe: receiver never receives the msg Pin
Member 7907192 at 28-Aug-11 21:25
memberMember 790719228-Aug-11 21:25 
Questionneed help to send sms through c# application Pin
hema12 at 17-Feb-11 1:09
memberhema1217-Feb-11 1:09 
Generalgsm modem project Pin
selcuk bekmezci at 4-Jan-11 12:50
memberselcuk bekmezci4-Jan-11 12:50 
Generalcode is not working please help me Pin
S.P.GUPTA at 10-Nov-10 5:18
memberS.P.GUPTA10-Nov-10 5:18 
GeneralMy vote of 5 Pin
Heaven2020 at 3-Nov-10 10:48
memberHeaven20203-Nov-10 10:48 
GeneralMy vote of 5 Pin
asghar2008 at 31-Oct-10 8:44
memberasghar200831-Oct-10 8:44 
GeneralHelp for Project Pin
By.W at 23-Oct-10 5:31
memberBy.W23-Oct-10 5:31 
GeneralRe: Help for Project Pin
Orhan Albay at 26-Oct-10 10:39
memberOrhan Albay26-Oct-10 10:39 

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 | Terms of Use | Mobile
Web01 | 2.8.150427.1 | Last Updated 25 Mar 2009
Article Copyright 2009 by namrata khandeparkar
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid