Sending sms

Submitted by LiL_Is on
Hi, I have a project to do and it is about sending sms through windows application.I'm using microsoft visual studios 2005 to do this application. I have the code and it is successfully send to the receiver but the receiver did not receive the sms. I'm using a modem to send the sms.Can anyone help me??? Here is the code: Imports System Imports System.Threading Imports System.ComponentModel Imports System.IO.Ports Public Class Form1 'connect your mobile/GSM modem to PC, 'then go in device manager and check under ports which COM port has been selected 'if say com1 is there then put com2 in following statement Dim SMSEngine As New SMSCOMMS("COM1") 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 End Class Public Class SMSCOMMS Private WithEvents SMSPort As SerialPort Private SMSThread As Thread Private ReadThread As Thread Shared _Continue As Boolean = False Shared _ContSMS As Boolean = False Private _Wait As Boolean = False Shared _ReadPort As Boolean = False Public Event Sending(ByVal Done As Boolean) Public Event DataReceived(ByVal Message As String) Public Sub New(ByRef COMMPORT As String) 'initialize all values SMSPort = New SerialPort With SMSPort .PortName = COMMPORT .BaudRate = 9600 .Parity = Parity.None .DataBits = 8 .StopBits = StopBits.One .Handshake = Handshake.RequestToSend .DtrEnable = True .RtsEnable = True .NewLine = vbCrLf End With End Sub Public Function SendSMS() As Boolean Dim ST As String Dim TimeOut As DateTime Dim Okay As Boolean = False If SMSPort.IsOpen = True Then SMSPort.WriteLine("AT+CMGF=1") ST = Nothing TimeOut = Now.AddSeconds(20) Do ST = SMSPort.ReadLine() Loop Until (ST IsNot Nothing) Or (Now > TimeOut) ' wait for OK If ST = "OK" Then SMSPort.WriteLine("AT+CSCA=""+6598540020"",145") ST = Nothing TimeOut = Now.AddSeconds(20) Do ST = SMSPort.ReadLine() Loop Until (ST IsNot Nothing) Or (Now > TimeOut) 'Wait for answer If ST IsNot Nothing Then SMSPort.WriteLine("AT+CSMP = 17, 167, 0, 16") ST = Nothing TimeOut = Now.AddSeconds(20) Do ST = SMSPort.ReadLine() Loop Until (ST IsNot Nothing) Or (Now > TimeOut) 'Wait for OK If ST = "OK" Then SMSPort.WriteLine("AT+CMGS= ""+" & Trim(Form1.TextBox1.Text) & """") ' Send the phone number ST = Nothing TimeOut = Now.AddSeconds(20) Do ST = SMSPort.ReadLine() Loop Until (ST IsNot Nothing) Or (Now > TimeOut) 'Wait for prompt If ST = ">" Then SMSPort.WriteLine(Form1.TextBox2.Text & Chr(26)) 'send the message ST = Nothing TimeOut = Now.AddSeconds(20) Do ST = SMSPort.ReadLine() Loop Until (ST IsNot Nothing) Or (Now > TimeOut) 'wait for confirmation If ST = "+CMGS: 62" Then MessageBox.Show("Message send") Okay = True End If End If End If End If End If SMSPort.Close() If Not Okay Then MessageBox.Show("Message not send") End If End Function Public Sub Open() If Not (SMSPort.IsOpen = True) Then SMSPort.Open() End If End Sub Public Sub Close() If SMSPort.IsOpen = True Then SMSPort.Close() End If End Sub End Class