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")
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
SMSPort.WriteLine("AT")
SMSPort.WriteLine("AT+CMGF=1" & vbCrLf)
SMSPort.WriteLine("AT+CSCA=""+919822078000""" & vbCrLf)
SMSPort.WriteLine("AT+CMGS= + TextBox1.text + " & vbCrLf)
_ContSMS = False
SMSPort.WriteLine("+ TextBox1.text +" & vbCrLf & Chr(26))
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
SMSEngine.Open()
SMSEngine.SendSMS()
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