Ozeki NG SMS Gateway logo OZEKI NG SMS Gateway
"The World's most reliable SMS gateway software!"
info@ozekisms.com
Tel.: 00 36 52 532 731
SMS Gateway to send SMS via GSM modem or IP SMS connection Overview SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Quick start SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Download SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Manual SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection How to buy SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection FAQ SMS Gateway to send SMS via GSM modem or IP SMS connection SMS Gateway to send SMS via GSM modem or IP SMS connection Contact Us SMS Gateway to send SMS via GSM modem or IP SMS connection
OZEKI NG SMS Gateway - Product Guide

Coldfusion SMS API Contents | SearchExamples and Solutions

Home > Product Manual > Developers Guide > VB 6 SMS API

SMS Gateway SMS Gateway Home

  Product Manual
  Introduction
  SMS technology
  Installation Guide
  User Guide
  Developers Guide
  Tutorials
  ASP SMS API
  PHP SMS API
  HTTP SMS API
  SQL SMS API
  C Sharp SMS API
  AJAX SMS API
  Delphi SMS API
  Cpp SMS API
  Java SMS API
  VB.NET SMS API
  Python SMS API
  Perl SMS API
  TCL/TK SMS API
  Coldfusion SMS API
  VB 6 SMS API
  Examples and Solutions
  Appendix
  FAQ
  Feature list
  Commercial Information
  Search
  Cookie policy
 


Automated phone calls?
Ozeki Phone System XE VoIP PBX software is an advanced PBX built for automated voice calls and 2 way SMS messaging. It has outstanding APIs for software developers. It can be used for:

Phone calls from SQL
Phone calls from HTTP
Voice and SMS applications

Callcenter developers
If you are working on telephone solutions, please check out the Ozeki VoIP SIP SDK.
It can be used to create VoIP client and server software.

Contact Us!
If you wish to get further information, do not hesitate to contact us!

E-mail: info@ozekisms.com

If you have a technical question, please submit a support request on-line.

How to send SMS message from Visual Basic

This guide provides you information on how to send SMS text messages from Visual Basic. Text messages will be sent from VB 6 through HTTP with HTTP GET method. To achieve this solution download and extract VB6_example.zip file below in which the whole project is available.

Download:vb6_example_for_excel_v1.1.xls
Download:vb6_example_for_access_v1.1.mdb

Download, extract VB6_example.zip and start the project.

On the appeared form provide the following values:

IP address: IP address of Ozeki NG SMS Gateway (127.0.0.1)
Port number: the port number of Ozeki NG SMS Gateway (9501)
Username: the username you use to log into Ozeki NG SMS Gateway (by default it is admin)
Password: the password used in Ozeki NG SMS Gateway (by default it is abc123)
Recipient: the phone number of the recipient (e.g. +36301122334)
Message: the body of the message (e.g. Test Message)

After filling the form click on Send Message (Figure 1).


Figure 1 - Provide values

On Figure 2 you can see the response from Ozeki NG SMS Gateway.


Figure 2 - Response from Ozeki NG SMS Gateway

Figure 3 demonstrates the sent message in Ozeki NG SMS Gateway.


Figure 3 - Sent message in Ozeki NG SMS Gateway

Source code

'This function opens an internet connection
Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" _
        (ByVal ozAgent As String, ByVal ozAccessType As Long, ByVal ozProxyName As String, _
        ByVal ozProxyBypass As String, ByVal ozFlags As Long) As Long

'This function handles the closing of the internet connection
        Private Declare Function InternetCloseHandle Lib "wininet" (ByRef ozInet As Long) As Long

'Reads the response file of the retrieved file requested by HTTP
Private Declare Function InternetReadFile Lib "wininet" _
        (ByVal ozGetFile As Long, ByVal ozBuffer As String, ByVal ozNumBytesToRead As Long,
        ozNumberOfBytesRead As Long) As Integer

'Opens an URL via the internet connection
Private Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" _
        (ByVal ozInternetSession As Long, ByVal ozUrl As String, ByVal ozHeaders As String, _
        ByVal ozHeadersLength As Long, ByVal ozFlags As Long, ByVal ozContext As Long) As Long

...

InternetOpen function creates Internet connection
InternetCloseHandle closes the connection
InternetOpenUrl opens an URL
InternetReadFile saves the HTTP response

...
'Sends the actual HTTP request

Private Function SendRequest(ByVal strUrl As String) As String
        Dim ozConnOpen As Long, ozGetFile As Long
        Dim ozReturnValue As Long, ozBuffer As String * 128
        Dim ozData As String

                ozConnOpen = InternetOpen("Ozeki HTTP client", 1, vbNullString, vbNullString, 0)

                If ozConnOpen = 0 Then
                        MsgBox "No Internet connection avaible"
                        Exit Function
                End If

        ozGetFile = InternetOpenUrl(ozConnOpen, strUrl, vbNullString, 0, &H4000000, 0)
                InternetReadFile ozGetFile, ozBuffer, 128, ozReturnValue
                ozData = ozBuffer
                        Do While ozReturnValue <> 0
                                InternetReadFile ozGetFile, ozBuffer, 128, ozReturnValue
                                ozData = ozData + Mid(ozBuffer, 1, ozReturnValue)
                        Loop

        InternetCloseHandle ozGetFile
        InternetCloseHandle ozConnOpen

        SendRequest = ozData
        ozData = ""
End Function
...
 

SendRequest function requests the URL

...
Private Sub Command1_Click()

    Dim ozIpaddr As String
    Dim ozPortNum As String
    Dim ozUser As String
    Dim ozPass As String
    Dim ozRecipient As String
    Dim ozMessage As String


        ozIpaddr = Text1.Text
        ozPortNum = Text2.Text
        ozUser = Text3.Text
        ozPass = Text4.Text
        ozRecipient = Text5.Text
        ozMessage = Text6.Text

Dim SendString As String

'SendString variable will contain the HTTP GET string, which will be used to send the message.

SendString = "http://" + ozIpaddr + ":" + ozPortNum _
    & "/api?action=sendmessage&username=" + ozUser _
    & "&password=" + ozPass _
    & "&recipient=" + ozURLEncode(ozRecipient) _
    & "&messagetype=SMS:TEXT&messagedata=" + ozURLEncode(ozMessage)

'Sending the SMS with the HTTP request, and writing the response xml to the frame

        Label7.Caption = SendRequest(SendString)

End Sub

...

Click event of Command1 button will execute the program and write the response XML

...

'This function will URL encode the characters in the HTTP request.

Function ozURLEncode(ByVal Text As String) As String
    Dim i As Integer
    Dim ozCode As Integer
    Dim char As String

    ozURLEncode = Text

    For i = Len(ozURLEncode) To 1 Step -1
        ozCode = Asc(Mid$(ozURLEncode, i, 1))
        Select Case ozCode
            Case 48 To 57, 65 To 90, 97 To 122
                ' Do not replace the alphanumeric characters
            Case 32
                ' Replace the space character with "+"
                Mid$(ozURLEncode, i, 1) = "+"
            Case Else
                ' Replace the national characters with a percent sign and the characters
                hexadecimal value
                ozURLEncode = Left$(ozURLEncode, i - 1) & "%" & Hex$(ozCode) & Mid$ _
                    (ozURLEncode, i + 1)
        End Select
    Next

End Function

ozURLEncode URL encodes its parameter





Next page: Examples and Solutions
Copyright © 2000 - 2017 Ozeki Informatics Ltd.
All rights reserved

Software PBX for Windows | VoIP SDK   |   Legal information   |   Privacy policy   |   Terms of use
Please, address your inquiries to info@ozekisms.com