Click here to Skip to main content
Licence CPOL
First Posted 25 Mar 2009
Views 126,856
Downloads 7,428
Bookmarked 47 times

vb.net AT commands to send SMS

By | 25 Mar 2009 | Article
this article allows you to send SMS to any mobile using GSM modem or your mobile connected via USB able to Computer

Introduction

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

Background

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

            SMSPort.WriteLine("AT")
            '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 in.net

License

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

Member

hello . I am studying BE in information technology in GOA.
My interests lie in programming in mobile communication in vb.net etc.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionyour code is not working with windows mobile PinmemberMu Shahid8hrs 55mins ago 
QuestionHeloo Pinmembersyahmi.rusli7:28 17 May '12  
QuestionRececiving ??? in my message PinmemberAmish Jariwala20:02 18 Apr '12  
Questiondoes not work on samsung mobile PinmemberMember 870981117:59 7 Mar '12  
Questionvb.net AT commands to send SMS Pinmembersmp from pune1:28 27 Feb '12  
QuestionDoes not work on Samsung Mobile PinmemberPatil Kishor0:27 13 Feb '12  
AnswerRe: Does not work on Samsung Mobile Pinmembershivayogirk23:03 14 Feb '12  
Questionsms in vb.net Pinmemberchimwemwe sinkamba2:50 30 Aug '11  
Questionproblem with this code PinmemberMember 79071921:48 25 Aug '11  
QuestionDoes NOT work PinmemberOnur Guzel2:40 19 Jul '11  
GeneralMy vote of 5 PinmemberRajiv nayan1:37 5 Jul '11  
Generalnokia3110 classic Pinmemberpkumar0091:51 29 May '11  
Generalproblem with coding Pinmemberpadmavath20:32 24 May '11  
QuestionWin7 and ports PinmemberNi8max4:07 23 May '11  
GeneralPORT IN USE ERROR PinmemberIgnatius Maziofa2:45 18 May '11  
GeneralMobile Broadband PinmemberMember 777059917:25 20 Mar '11  
Questionreceiver never receives the msg Pinmemberbasheer.j16:47 12 Mar '11  
AnswerRe: receiver never receives the msg PinmemberMarko Joksimovic15:01 8 May '11  
AnswerRe: receiver never receives the msg PinmemberMember 790719220:25 28 Aug '11  
Questionneed help to send sms through c# application Pinmemberhema120:09 17 Feb '11  
Generalgsm modem project Pinmemberselcuk bekmezci11:50 4 Jan '11  
Generalcode is not working please help me PinmemberS.P.GUPTA4:18 10 Nov '10  
GeneralMy vote of 5 PinmemberHeaven20209:48 3 Nov '10  
GeneralMy vote of 5 Pinmemberasghar20087:44 31 Oct '10  
GeneralHelp for Project PinmemberBy.W4:31 23 Oct '10  

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.

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