Send SMS Via HSDPA Modem Using VB.NET

97 views
Skip to first unread message

prageeth

unread,
Jun 22, 2010, 2:44:46 AM6/22/10
to ICBTSouthernIT
I think this is very important to ALL...
If u want to send SMS By using Computer You Can use Several Methods
1) using SMS Server(Ozeki Server.Any Ques ask From Mr.Aruna Indika)
2) using Email to SMS
3) using Third Party WEB Site
4) using Modem Software

Some times You Want to Attach this Facility to Your Own Software, This
is the Code....

Imports System.IO.Ports
Public Class Form1

Private strPort As String = String.Empty
Private WithEvents sp As SerialPort
Private strBuffer As String = String.Empty
Private Delegate Sub UpdateBufferDelegate(ByVal Text As String)

Public Sub SendTextMessage(ByVal [To] As String, ByVal Message As
String)
strPort = "COM2"
sp = My.Computer.Ports.OpenSerialPort(strPort)
SendData("ATZ" & vbCr, "OK")
SendData("AT+CMGF=1" & vbCr, "OK")
SendData("AT+CMGS=" & Chr(34) & [To] & Chr(34) & vbCr, ">")
SendData(Message & vbCr, ">")
SendData(Chr(26), "OK")

sp.Close()

End Sub

Public Sub SendEmail(ByVal [To] As String, ByVal Subject As
String, ByVal Body As String)

sp = My.Computer.Ports.OpenSerialPort(strPort)

SendData("ATZ" & vbCr, "OK")
SendData("AT+CMGF=1" & vbCr, "OK")
SendData("AT+CMGS=" & Chr(34) & "500" & Chr(34) & vbCr, ">")
SendData([To] & " " & Subject & "# " & Body & vbCr, ">")
SendData(Chr(26), "OK")

sp.Close()

End Sub

' Send data without waiting for specific response
Private Sub SendData(ByVal Data As String)

sp.Write(Data)

End Sub

' Send data and wait for a specific response
Private Sub SendData(ByVal Data As String, ByVal WaitFor As
String)

sp.Write(Data)
WaitForData(WaitFor)

End Sub

Private Function WaitForData(ByVal Data As String, Optional ByVal
Timeout As Integer = 10) As Boolean

Dim StartTime As Date = Date.Now

Do
If InStr(strBuffer, Data) > 0 Then
strBuffer = strBuffer.Substring((InStr(strBuffer,
Data) - 1) + Data.Length)
Return True
End If

If Date.Now.Subtract(StartTime).TotalSeconds >= Timeout
Then
Return False
End If
Loop

End Function

Private Sub UpdateBuffer(ByVal Text As String)

strBuffer &= Text

End Sub

Private Sub sp_DataReceived(ByVal sender As Object, ByVal e As
SerialDataReceivedEventArgs) Handles sp.DataReceived

Dim dUpdateBuffer As New UpdateBufferDelegate(AddressOf
UpdateBuffer)
Dim strTmp As String = sp.ReadExisting

dUpdateBuffer.Invoke(strTmp)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
SendTextMessage("0777934206", "Testing SMS")
End Sub
End Class

IF ANY QUES Mail to Me



Dulitha Muthukumara

unread,
Jun 24, 2010, 10:14:48 PM6/24/10
to icbtsou...@googlegroups.com
Thanx friend ...KIT
Reply all
Reply to author
Forward
0 new messages