Quicklinks
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:
The Gsm object is part of the ActiveXperts SMS Component. Overview of all SMS Component objects:
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."
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
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."
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.