Click here to Skip to main content
12,702,575 members (34,397 online)
Click here to Skip to main content
Add your own
alternative version


60 bookmarked
Posted 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.

You may also be interested in...

Comments and Discussions

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

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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
Web02 | 2.8.170118.1 | Last Updated 25 Mar 2009
Article Copyright 2009 by namrata khandeparkar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid