.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to write an application to send sms in vb.net

Posted By:gabor.szuros       Posted Date: May 16, 2014    Points: 200    Category: .Net Framework    URL: http://www.dotnetspark.com  

In this arcitcle you can learn how to write an application in vb.net to send sms with an sms gateway.


In the last 15 years the technology and the communication methods showed outstanding improvements. There is plenty of undiscovered opportunites in this sector. One of them is sms implementation. The potencial in the SMS communication sector will increase in the next five years.

It is faster, cheaper and more efficient than other marketing tool. The opening rate of SMS messages is 97%. There is no other marketing tool like the SMS marketing if you wish to reach your consumers. You can check every detail about your message in a delivery report and with good marketing you can engage consumers to your company. With a VB.Net programming language you are able to write or implement an sms sending / receiving solution to your system in a fast and easy way.

Prerequisites to send / receive sms messages in Vb.Net

  1. This code is written in VB.Net, so you need an IDE (Integrated Development Environment) supporting this programming language, such as Microsoft Visual Studio.
  2. This method is based by sending a http request to an SMS Gateway so you will need one. I already use an SMS Gateway so I show the example with this software.
  3. I have a direct SMPP connection so there can be difference in sending sms with a gsm modem.

Creating the IDE to start writing the application

  • Open the Visual Studio software
  • Create a new project by clickin the file->new project-> new windows form application
  • Open the code sheet and start writing the code

Writing the code

Step - 1. Connection to SMS Gateway.

If you open the create a new project, and start the following section in the code section:

Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim url As String Dim username As String = "admin"
Dim password As String = "abc123"
Dim host As String = ""
Dim originator As String = "06201234567" 

With these commands you can connect to the SMS Gateway. This code specifies that you will send a http request, it will provide you username, password, host- and phone number to the SMS Gateway. Modify these values to match with your personal data.

Step - 2 - Composition of the URL This is the code for creating an URL.

This code will be posted to the SMS Gateway.

url = host + "/api?action=sendmessage&" _
& "username=" & HttpUtility.UrlEncode(username) _
& "&password=" + HttpUtility.UrlEncode(password) _
& "&recipient=" + HttpUtility.UrlEncode(tbReceiver.Text) _
& "&messagetype=SMS:TEXT" _
& "&messagedata=" + HttpUtility.UrlEncode(tbMessage.Text) _
& "&originator=" + HttpUtility.UrlEncode(originator) _ &
"&serviceprovider=" _ & "&responseformat=html" 

  • Sender's username: Captures your login name.
  • Sender's password: Captures your password.
  • Recipient: Captures the recipients number.
  • Message type: Type of message. In this case text sms
  • Message data: Captures the content of message. The SMS will be a text message
  • Originator: Captures the sender's phone number.
  • Service provider: Captures the name wich service provider you wish to send the text message
  • Response format: Captures the answer's type.

Step - 3 - Submit the URL To send your SMS message you need to initiate a HTTP request.

This is the code to add how you wish to send the URL out.

request = DirectCast(WebRequest.Create(url), HttpWebRequest) 

This row presents the method of the answer.

response = DirectCast(request.GetResponse(), HttpWebResponse) 

The following code provides the method, how the answer should be displayed.

MessageBox.Show("Response: " & response.StatusDescription) 

After you gave what the URL have to contain what will be it's route and how the application should answer you click ont he run application button and your message will sent.

Please note that as you test your application, take care of any expenses you may be generating for yourself or another person as you sending the text messages.



Download link to softwares:

Download Microsoft Visual Studio: http://www.microsoft.com/hu-hu/download/visualstudio.aspx?q=visual+studio Download

Ozeki NG SMS Gateway: http://ozekisms.com/index.php?owpn=112

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply

    Read also another Resources from the same Author

Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend