Sub SendSMS() If Modem.IsOpen = False Then MsgBox("Port not Open!!") Exit Sub End If If Me.TxtTo.Text = "" Then MsgBox("No recepient number!!") Exit Sub End If If Me.TxtSMS.Text = "" Then MsgBox("Blank text message are not allowed!!") Exit Sub End If sendbutton.Enabled = False Sending = True SendAttempt = 0 Do ATSend("AT+CMGF=1") Result = ATRead(1000) Loop While Result.Contains("COMMAND NOT SUPPORT") Do ATSend("AT+CSMP=17,167,0,0") Result = ATRead(1000) Loop While Result.Contains("COMMAND NOT SUPPORT") Do Do ATSend("AT+CMGS=""" & TxtTo.Text & """") Result = ATRead(1000) Loop While Result.Contains("COMMAND NOT SUPPORT") ATSend(TxtSMS.Text & Char.ConvertFromUtf32(26) & vbCr) 'ATSend(MyMessage & Char.ConvertFromUtf32(26) & vbCr) 'ATSend(MyMessage & vbCrLf & Chr(26)) Result = ATRead(10000) SendAttempt += 1 Loop While Result.Contains("COMMAND NOT SUPPORT") Or (Result.Contains("ERROR") And SendAttempt < 5) If Result.EndsWith(vbCrLf & "OK" & vbCrLf) Then TxtSMS.Text = "" TxtTo.Text = "" ' MsgBox("Message Successfully Sent") Else ' MsgBox("Message Could Not Be Sent", MsgBoxStyle.Critical, "Error") End If sendbutton.Enabled = True Sending = False End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)