Send SMS using AT command

Send SMS using GSM modem from your computer. This Example shows you to use AT command to handle the GSM modem.
Try this to send SMS using this example.

1- Insert a form in VB project
2- Insert textbox (txtMsg,txtDestinationNumber)
3- Insert command button (Command1)
4- Insert a MSComm1
5- Connect your mobile phone in computer with datacable

Private Sub Command1_Click()
Call SENDSMS
End Sub

Sub SENDSMS()
On Error GoTo Errr:
If MsgBox("Are you sure to send SMS Message", vbYesNo) = vbNo Then
    Exit Sub
End If
' Set up the communications port
MSComm1.CommPort = 5 ' Com Port 5
' Set for 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
MSComm1.InputLen = 0
MSComm1.PortOpen = True
MSComm1.Output = "AT" & Chr$(13)
' Set up the phone for a text message
MSComm1.Output = "AT+CMGF=1" & Chr$(13)
MSComm1.Output = "AT+CMGS= " & Chr(34) & txtDestinationNumber.Text & Chr(34) & Chr$(13) & Chr(10)
MSComm1.Output = txtMsg.Text & Chr$(26)
MSComm1.PortOpen = False
MsgBox "Message Sent successfully"
Exit Sub
Errr:
MsgBox Err.Description & Err.Number, vbExclamation

End Sub
Advertisements

6 Responses

  1. Hey, thank u so much, ive been searching the internet for months to sent sms with vb. Your solution is the only one of hundreds that works. So glad i found this site. Thanks again.

  2. Awesome.
    How can I read the report that confirms that the SMS is received by the recipient cell phone, a.k.a receive report?

  3. Hey Nitin,

    For that you need to read your confirm message from Mobile, After delivered the SMS your sms center will send a delivered message, then you need to read that SMS again.

    Regards,
    Raghunath Bhandari

  4. I tried this application on Nokia 3110, connected to PC (XP) via USB cable. The control panel shows COM 8 as the designated port.
    It does not send the SMS. What could be the problem?
    Prev. I had used ATSMS library and it worked perfectly.

  5. Can you give me sample program in vb that will read all messages in my modem? thanksssss

  6. Use this codes in VB and connect your Mobile phone or GSM modem in PC then it will work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: