Code Sample:
Private Function SendSMS_txtLocal(ByVal Test As Boolean, _
ByVal From As String, _
ByVal Message As String, _
ByVal SendTo As String, _
ByVal URL As String) As String
' Send a message using the txtLocal transport
Const TransportURL As String =" https://www.bulksmsgateway.in/sendmessage.php"
Const TransportUserNameAs String =9030888111
Const TransportPasswordAs String ="mypassword"
Const TransportVerboseAs Boolean =True
Dim strPost As String
' Build POST String
strPost = "user=" + TransportUserName + "&password=" + TransportPassword + "&message=" + System.Web.HttpUtility.UrlEncode(Message) +
"&sender=" + OPTINS + "&mobile=" + SendTo + "&type=1"
If URL = "" Then
strPost += "&url=" + URL
End If
If Test = True Then
strPost += "&test=1"
End If
If TransportVerbose =True Then
strPost += "&info=1"
End If
' Create POST
Dim request As WebRequest = WebRequest.Create(TransportURL)
request.Method = "POST"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(strPost)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
' Get the response.
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServerAs String = reader.ReadToEnd()
' Clean upthe streams.
reader.Close()
dataStream.Close()
response.Close()
' Return result to calling function
If responseFromServer.Length > 0 Then
Return responseFromServer
Else
Return CType(response, HttpWebResponse).StatusDescription
End If
End Function
Please note that some of the above code has been supplied to Bulk SMS Gateway by clients. As such, accuracy is not guaranteed by Bulk SMS Gateway.