Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
anyone can help me to make sms gateway application using vb.net (desktop application).....?

please help me.....
Posted
Updated 31-Jan-12 23:15pm
v2

Anyone can help me ,I want to make SMS gateway Server (using GSMModem) and its for my school. And I want my App be E-Controlling Software. :) (I'm sorry my English is bad)
 
Share this answer
 
Comments
CHill60 4-Mar-15 11:10am    
If you have a question then use the "Ask a Question" link - don't post questions as solutions to old answers - few people will see it.
However, this is a Quick answers forum so you will have to try something for yourself before posting a question. Use a search engine to do some research and give it a try first... there are plenty of resources here on CodeProject if you type SMS into the search box!
Imports System.Data
Imports System.IO
Imports System.Configuration
Imports System
Imports System.Net
Imports System.Text

Public Function SendSMS(ByVal User As String, ByVal password As String, ByVal Mobile_Number As String, ByVal Message As String, Optional ByVal MType As String = "N") As String
Dim stringpost As String = "User=" & User & "&passwd=" & password & "&mobilenumber=" & Mobile_Number & "&message=" & Message & "&MTYPE=" & MType
'Response.Write(stringpost)
Dim functionReturnValue As String = Nothing
functionReturnValue = ""

Dim objWebRequest As HttpWebRequest = Nothing
Dim objWebResponse As HttpWebResponse = Nothing
Dim objStreamWriter As StreamWriter = Nothing
Dim objStreamReader As StreamReader = Nothing

Try
Dim stringResult As String = Nothing

objWebRequest = DirectCast(WebRequest.Create("http://Domain name/WebserviceSMS.aspx"), HttpWebRequest)
//domain name: Domain name Replace With Your Domain
objWebRequest.Method = "POST"

' Response.Write(objWebRequest)

' Use below code if you want to SETUP PROXY.
'Parameters to pass: 1. ProxyAddress 2. Port
'You can find both the parameters in Connection settings of your internet explorer.

' If you are in the proxy then Uncomment below lines and enter IP and Port.
' Dim myProxy As New Net.WebProxy("192.168.1.108", 6666)
'myProxy.BypassProxyOnLocal = True
'objWebRequest.Proxy = myProxy

objWebRequest.ContentType = "application/x-www-form-urlencoded"

objStreamWriter = New StreamWriter(objWebRequest.GetRequestStream())
objStreamWriter.Write(stringpost)
objStreamWriter.Flush()
objStreamWriter.Close()

objWebResponse = DirectCast(objWebRequest.GetResponse(),HttpWebResponse)


objWebResponse = DirectCast(objWebRequest.GetResponse(), HttpWebResponse)

objStreamReader = New StreamReader(objWebResponse.GetResponseStream())
stringResult = objStreamReader.ReadToEnd()
objStreamReader.Close()
Return (stringResult)
Catch ex As Exception
Return (ex.ToString)
Finally

If (objStreamWriter IsNot Nothing) Then
objStreamWriter.Close()
End If
If (objStreamReader IsNot Nothing) Then
objStreamReader.Close()
End If
objWebRequest = Nothing
objWebResponse = Nothing

End Try
End Function

Protected Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
Dim str As String
str = SendSMS(Trim(User1.Value), Passwd.Value, mobilenumber.Value, message.Value)
Response.Write(str)
End Sub
 
Share this answer
 
VB
Imports System.Net
Imports System.Text
Imports System.IO

Module Module1

    Sub Main()

        SendSMS("18479790553", "ToNumber", "I am coming there")

    End Sub
    Sub SendSMS(ByVal FromNumber As String, ByVal ToNumber As String, ByVal SMS As String)

        Dim url As String = "http://www.sendandreceivesms.com/api/"
        Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
        request.Method = "POST"
        Dim postData As String = "FromNumber=" & FromNumber
        postData += "&"
        postData += "ToNumber=" & ToNumber
        postData += "&"
        postData += "SMS=" & SMS
        Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
        request.ContentType = "application/x-www-form-urlencoded"
        request.Headers.Add("APIToken", "GoOu9H0h9G")'get your new API token at https://www.sendandreceivesms.com
        request.ContentLength = byteArray.Length
        Dim dataStream As Stream = request.GetRequestStream()
        dataStream.Write(byteArray, 0, byteArray.Length)
        dataStream.Close()
        Dim response As WebResponse = request.GetResponse()
        dataStream = response.GetResponseStream()
        Dim reader As New StreamReader(dataStream)
        Dim responseFromServer As String = reader.ReadToEnd() 'Log This in DB, Queue msgs that failed so that they can be sent again when console app runs
        reader.Close()
        dataStream.Close()
        response.Close()
    End Sub

End Module
 
Share this answer
 
It's a frequent question here in CP, so browse here SMS related questions/answers - Codeproject Search[^]

You can find many articles & past questions with multiple answers, Enjoy.
 
Share this answer
 
Comments
Espen Harlinn 26-Jan-12 11:01am    
5'ed!
Rajesh Anuhya 1-Feb-12 5:18am    
+5 for CP, not for Raja ;-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900