Shortcut Menu

Skip

Main Navigation

Choose your language


ActiveXperts SMS Component Add SMS capabilities to any Windows or .NET application

Quicklinks


SMS Component - Gsm object

Overview

A GSM modem is a wireless modem that connects to a GSM compatible wireless network. For the purpose of sending SMS messages any modem that supports the GSM 07.07 command set to send out SMS messages can be considered a GSM modem.

A GSM modem can be an external device that's connected to a host PC through a USB or a COM interface or it can be an internal PC card. Some GSM phones also support option to function as a GSM modem. Like a GSM mobile phone, the GSM modem requires a SIM card from a wireless carrier in order to operate.

The SMS Component supports GSM modems through its Gsm object.

The Gsm object features the following:

  • Send SMS messages through a GSM modem
  • SMS messages can be alphanumeric, unicode or binary
  • Templates are included for WAPPush and vCard messages
  • Verify that messages are delivered through status reports
  • Supports automatically splitting up / re-assembling multipart messages
  • GSM Supports Windows 'Phone and Modem devices' (TAPI) and direct COM ports

The Gsm object is part of the ActiveXperts SMS Component. Overview of all SMS Component objects:

  • Gsm - Send and receive SMS messages using a GSM modem or a modem-capable GSM phone.
  • Smpp - Send and receive SMS messages via an SMPP provider.
  • SmppServer - Accept incoming SMPP connections.
  • Http - Send SMS messages through an HTTP based SMSC provider interface over the internet.
  • Dialup - Send SMS messages using a Hayes compatible modem through TAP/XIO or UCP.
  • Snpp - Send pager messages via an SNPP provider through the internet/VPN.

Sample code

VBScript sample: Send a plain text SMS message via GSM modem/phone

Option Explicit

Dim objGsm, objSmsMessage, objSmsConstants, objStatusReport
Dim strPin, strReference, strDevice
Dim bSearchStatusReport

Set objGsm                    = CreateObject ( "AxSms.Gsm" )
Set objSmsMessage             = CreateObject ( "AxSms.Message" )
Set objSmsConstants           = CreateObject ( "AxSms.Constants" )

' Select Device
strDevice                     = "COM1"

' Open connection to the device
objGsm.Open strDevice
WScript.Echo "Open, result: " & objGsm.LastError

If (objGsm.LastError <> 0) Then
  WScript.Echo "Ready."  
  WScript.Quit  
End If

' Message: set all properties
objSmsMessage.Clear
objSmsMessage.ToAddress       = "+31612345678"
objSmsMessage.Body            = "Hello, world!"

' Send the message 
WScript.Echo "Sending the message..."
objGsm.SendSms( objSmsMessage )  
WScript.Echo "SendSms, result: " & objGsm.LastError

objGsm.Close
WScript.Echo "Ready."

VB .NET sample: Send a plain text SMS message via GSM modem/phone

Imports AxMmCtlLib
Imports System.IO
Imports System.Threading

Module GsmProgram

  Sub Main()
    Dim objGsm As Gsm = New Gsm() ' Create instance of COM Object
    Dim objSmsMessage As SmsMessage = New SmsMessage() ' Create instance of COM Object
    Dim objSmsConstants As SmsConstants = New SmsConstants() ' Create instance of COM Object
    Dim objStatusReport As GsmDeliveryReport = Nothing

    objGsm.Open("COM1", String.Empty, 0)
    Console.WriteLine("Open, result: " &  objGsm.LastError.ToString() )
    If (objGsm.LastError <> 0) Then
      GoTo _EndMain
    End If

    ' Message settings
    objSmsMessage.ToAddress = "+31612345678"
    objSmsMessage.Body = "Hello, world!"
    
    ' Send the message !
    objGsm.SendSms( objSmsMessage, objSmsConstants.MULTIPART_OK, 25000 )
    Console.WriteLine("SendSms, result: " & objGsm.LastError.ToString() )
    If (objGsm.LastError <> 0) Then
      GoTo _EndMain
    End If

    objGsm.Close() ' Make sure the port gets closed

    Console.WriteLine("Ready.")
    
End Sub
 

VBScript sample: Receive a plain text SMS message via GSM modem/phone

Option Explicit

' Declare Objects
Dim objGsm, objSmsMessage, objSmsConstants, strPin, strDevice

' Create Objects
Set objGsm                    = CreateObject ( "AxSms.Gsm" )
Set objSmsConstants           = CreateObject ( "AxSms.Constants" )

' Open connection to the device
objGsm.Open "COM1"
WScript.Echo "Open, result: " & objGsm.LastError
If (objGsm.LastError <> 0) Then
  WScript.Echo "Ready."  
  WScript.Quit  
End If

' Receive messages
WScript.Echo "Receiving messages..."
objGsm.Receive objSmsConstants.GSM_MESSAGESTATE_RECEIVED_UNREAD, False, 
               objSmsConstants.GSM_STORAGETYPE_ALL
WScript.Echo "Receive, result: " & objGsm.LastError
If ( objGsm.LastError <> 0 ) Then 
  objGsm.Close
  WScript.Quit
End If

' Retrieve messages one by one
Set objSmsMessage = objGsm.GetFirstSms
WScript.Echo "GetFirstSms, result: " & objGsm.LastError 
While ( objGsm.LastError = 0 )
  WScript.Echo "  Message from: " & objSmsMessage.FromAddress
  
  If (objSmsMessage.BodyFormat = objSmsConstants.BODYFORMAT_HEX) Then
    WScript.Echo "  Message body: <DATA>"
  Else
    WScript.Echo "  Message body: " & objSmsMessage.Body
  End If
  Set objSmsMessage = objGsm.GetNextSms()
  WScript.Echo "GetNextSms, result: " & objGsm.LastError 
Wend

' Ready
objGsm.Close
WScript.Echo "Ready."

More samples

Samples are available for: C# .NET, Visual Basic .NET, Visual C/C++, VBA, ASP, ASP .NET, Java, Javascript, PHP, HTML, ColdFusion, Delphi and more.

On ftp.activexperts-labs.com, you can find many SMS Component samples. Samples are also part of the SMS Component installation.