Click here to Skip to main content
13,355,538 members (71,827 online)
Click here to Skip to main content
Add your own
alternative version


61 bookmarked
Posted 25 Mar 2009 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.

You may also be interested in...


Comments and Discussions

Questionhow do I send 1 sms to multi receiver ? Pin
Member 1321222924-May-17 3:00
memberMember 1321222924-May-17 3:00 
QuestionBulk Messages/Text Blast Pin
Member 1300571416-Feb-17 7:00
memberMember 1300571416-Feb-17 7:00 
QuestionReceiving Message Code Pin
Member 1300571416-Feb-17 6:58
memberMember 1300571416-Feb-17 6:58 
Question100 % Working Pin
Member 1300571416-Feb-17 7:23
memberMember 1300571416-Feb-17 7:23 
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 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 25 Mar 2009
Article Copyright 2009 by namrata khandeparkar
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid