You are on page 1of 7

15,684,972 members Sign in

articles quick answers discussions features community help Search for articles, questions, tips

Articles / Programming Languages / Visual Basic


 

vb.net AT commands to send SMS


namrata khandeparkar Rate me: 4.81/5 (24 votes)

25 Mar 2009 CPOL 1 min read

this article allows you to send SMS to any mobile using GSM modem or your mobile connected via USB able to Computer

Download WindowsApplication1_code_project_ - 23.82 KB

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.

VB Shrink ▲  
//
// 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)

Written By

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

Comments and Discussions


 

You must Sign In to use this message board.

Search Comments

Spacing Relaxed   Layout Normal   Per page 25     Update

First Prev Next

Receive an SMS Member 12613507 9-Aug-20 16:09 

how do I send 1 sms to multi receiver ? Member 13212229 24-May-17 2:00 

Bulk Messages/Text Blast Member 13005714 16-Feb-17 6:00 


Re: Bulk Messages/Text Blast iggyjig 14-Nov-18 15:22 

Receiving Message Code Member 13005714 16-Feb-17 5:58 

100 % Working Member 13005714 16-Feb-17 6:23 

Small project for Namrata (sms component) Member 11640868 24-Apr-15 22:26 

I want same code in VB6. Can you give me ? Rahul Kanchan 17-Mar-15 17:13 

Solved niranjanbhuta2006 12-May-14 1:24 

not working in samsung galaxy s4 Member 10644554 6-Mar-14 1:42 

nokia c2-02 & nokia 2700 classic Member 8060420 15-Dec-13 3:13 

how i can send sms in asp.net? irfanansari 21-Sep-13 1:57 

.PortName = COMMPORT irfanansari 30-Aug-13 23:13 

My Application freezes Kashif Alvi 25-Aug-13 5:21 

It work, but change something sennetwork 20-Jun-13 21:35 

My vote of 5 mohajery 6-Jun-13 7:56 

My phone is restarting.. ngagebhavik 12-Apr-13 22:51 


Not Working.. bandhalaraja 31-Jan-13 18:33 

Re: Not Working.. sennetwork 20-Jun-13 21:36 

TimeoutException was unhandled ArthurWong89 23-Jan-13 4:40 

Message center number Dibu.net 3-Jan-13 1:57 

My vote of 4 saqibsabir 25-Dec-12 18:45 

Not Sending Help Please saqibsabir 25-Dec-12 7:53 

PORT ERROR. Anz Tara 18-Dec-12 20:42 

not sending agung.imannuel 2-Oct-12 1:42 

Last Visit: 27-Jun-23 10:17     Last Update: 28-Jun-23 8:53 Refresh 1 2 3 4 5 Next ᐅ

General    News    Suggestion    Question    Bug    Answer    Joke    Praise    Rant    Admin   

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

Permalink Layout: fixed | fluid Article Copyright 2009 by namrata khandeparkar


Advertise Everything else Copyright © CodeProject, 1999-2023
Privacy
Cookies Web02 2.8:2023-05-13:1
Terms of Use

You might also like