An easy and simple way to use VOIP services available on the web to send cheap SMS (Messages).
SMS - Sending Page
Source Code:Imports System.Net
Imports System.IO
Public Class Form1
Dim LS As New LSettings 'Classe of SMS Server Config
Dim SMSserver, User, Pass, Remetente, Destinatario, SMStext As String
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If txt_destinatario.Text = String.Empty Or txt_msg.Text = String.Empty Then
MessageBox.Show("Number or Message can not be Empty!")
Else
Cursor = Cursors.WaitCursor
' Create a new web client to send the requestDim client As WebClient = New WebClient()SMSserver = LS.server
User = LS.user
Pass = LS.pass
Remetente = LS.remetente
Destinatario =
"Country Code EX: 00351 " & txt_destinatario.Text & ""SMStext = "" & txt_msg.Text & ""
' Set the URL to send the request to, please note' you can use either HTTP or HTTPS
Dim url As String = _
"https://" _& SMSserver &
"username=" _& User &
"&password=" _& Pass &
"&from=" _& Remetente &
"&to=" _& Destinatario &
"&text=" _& SMStext &
""
Try
' Send the request and read the response
Dim stream As Stream = client.OpenRead(url)
Dim reader As StreamReader = New StreamReader(stream)
Dim response As String = reader.ReadToEnd()
' Close the data stream and HTTP connection
stream.Close()
reader.Close()Catch ex As ExceptionMsgBox(ex.Message _
& vbNewLine _
& "The message is in sending state")
End Try
Cursor = Cursors.Default
lblSMSinfo.Visible = True
End If
End Sub
Private Sub txt_destinatario_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txt_destinatario.MouseClick
lblSMSinfo.Visible = False
End Sub
Private Sub bt_limpar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_limpar.Click
txt_destinatario.Clear()
txt_msg.Clear()
lblSMSinfo.Visible = False
End Sub
Private Sub SettingsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettingsToolStripMenuItem.Click
SMSSettings.Show()
End Sub
'Limit insert text only numbers
Private Sub txt_destinatario_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_destinatario.KeyPress
Dim KeyAscii As Short = CShort(Asc(e.KeyChar))
KeyAscii = CShort(LS.ValidarNumero(KeyAscii, "0123456789"))
If KeyAscii = 0 Then
e.Handled = True
End If
End Sub
End Class
SMS - Config. SMS Server Page
Source Code:
Private _server As StringPrivate _user As StringPrivate _pass As StringPrivate _remetente As String
Public Property server() As String
Get
Return _server
End Get
Set(ByVal value As String)
_server = value
End Set
End Property
Public Property user() As StringGet
Return _user
End Get
Set(ByVal value As String)
_user = value
End Set
End Property
Public Property pass() As String
Get
Return _pass
End Get
Set(ByVal value As String)
_pass = value
End Set
End Property
Public Property remetente() As String
Get
Return _remetente
End Get
Set(ByVal value As String)
_remetente = value
End Set
End Property
Public Sub Settings(ByVal Dserver As String, ByVal Duser As String, _
ByVal Dpass As String, ByVal Dremetente As String)
server = Dserveruser = Duser
pass = Dpass
remetente = Dremetente
End Sub
Public Function ValidarNumero(ByVal Keyascii As Short, ByVal filtroDados As String) As Short'filtroDados = "0123456789,-+" Exemplo
If InStr(filtroDados, Chr(Keyascii)) = 0 Then
ValidarNumero = 0
ElseValidarNumero = Keyascii
End If
Select Case Keyascii
Case 8
ValidarNumero = Keyascii
Case 13
ValidarNumero = Keyascii
Case 32
ValidarNumero = Keyascii
End Select
End Function
End Class
