SMS and MMS Toolkit - SmsProtocolGsm object

Overview

A GSM modem is a wireless modem that works with a GSM wireless network. A wireless modem behaves like an ordinary dial-up modem. The difference between them is that a dial-up modem sends and receives data through a fixed telephone line, while a wireless modem sends and receives data through GSM.

A GSM modem can be an external (USB/COM) device or a PC Card. Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless carrier in order to operate.

SMS and MMS Toolkit supports GSM modems through its SmsProtocolGsm object.

The SmsProtocolGsm object features the following:

The SmsProtocolGsm object is part of the ActiveXperts SMS and MMS Toolkit component. Overview of all SMS and MMS Toolkit objects:

Sample code

VBScript sample: Send a plain text SMS message (via GSM/GPRS modem or phone)

Set objGsmProtocol = CreateObject ( "ActiveXperts.SmsProtocolGsm" )
Set objSmsMessage = CreateObject ( "ActiveXperts.SmsMessage" )
Set objConstants = CreateObject ( "ActiveXperts.SmsConstants" )

objGsmProtocol.Device = "MultiTech GSM MultiModem" ' Use Windows Telephony device 
objGsmProtocol.EnterPin ( "1234" ) ' SIM card's PIN code

objSmsMessage.Clear
objSmsMessage.Recipient = "+31624896641" ' Recipient's mobile number
objSmsMessage.Data = "Hello, world!" ' SMS message text

objGsmProtocol.Send( objSmsMessage )	
WScript.Echo "Result: " & objGsmProtocol.LastError

VB .NET sample: Send a plain text SMS message (via GSM Modem / GSM phone)

Imports AXmsCtrl

Module Module1
  Sub Main()

    Dim objGsmProtocol As SmsProtocolGsm = New SmsProtocolGsm
    Dim objSmsMessage As SmsMessage = New SmsMessage

    objGsmProtocol.Device = "COM1" ' Device Settings 

    objSmsMessage.Clear()
    objSmsMessage.Recipient = "31647134225" ' Message Settings 
    objSmsMessage.Data = "ActiveXperts SMS and MMS Toolkit GSM test message!"

    objGsmProtocol.Send(objSmsMessage) ' Send the message 
    Console.WriteLine( "Send message, result: {0} ( {1} )", 
    objGsmProtocol.LastError.ToString, 
    objGsmProtocol.GetErrorDescription( objGsmProtocol.LastError ) )
  End Sub
 End Module
 

VBScript sample: Receive a plain text SMS message (GSM Modem / GSM phone)

Set objGsmProtocol = CreateObject ( "ActiveXperts.SmsProtocolGsm" )

objGsmProtocol.Device = "MultiTech GSM MultiModem"
objGsmProtocol.DeleteAfterReceive = FALSE ' Don't delete after receive
objGsmProtocol.EnterPin ( "1234" ) ' SIM card's PIN code

objGsmProtocol.Receive() ' Receive messages from SIM/memory 
If ( objGsmProtocol.LastError <> 0 ) Then 
 WScript.Echo "Failed to receive, error: " & objGsmProtocol.LastError
 WScript.Quit
End If

' Iterate over all received messages
On Error Resume Next
Set objSmsMessage = objGsmProtocol.GetFirstMessage()
On Error Goto 0
If( objGsmProtocol.LastError = 33060 ) Then
 WScript.Echo "No messages received."
ElseIf( objGsmProtocol.LastError <> 0  ) Then 
 WScript.Echo "GetFirstMessage, result: " & objGsmProtocol.LastError
Else
 While( objGsmProtocol.LastError = 0 ) 
   WScript.Echo "Message from: " & objSmsMessage.Sender
   If( objSmsMessage.Format = objConstants.asMESSAGEFORMAT_DATA ) Then
     WScript.Echo "  " & "<DATA>"
   Else
     WScript.Echo "  " & objSmsMessage.Data
   End If
   WScript.Echo
   On Error Resume Next
   Set objSmsMessage = objGsmProtocol.GetNextMessage()
   On Error Goto 0
 Wend
End If

VBScript sample: Send a Unicode SMS message (via GSM Modem / GSM phone)

Set objGsmProtocol = CreateObject ( "ActiveXperts.SmsProtocolGsm" )
Set objSmsMessage = CreateObject ( "ActiveXperts.SmsMessage" )
Set objConstants = CreateObject ( "ActiveXperts.SmsConstants" )

objGsmProtocol.Device = "MultiTech GSM MultiModem" ' Use a Windows Telephony device 
objGsmProtocol.EnterPin ( "1234" ) ' SIM card's PIN code

objSmsMessage.Clear
objSmsMessage.Recipient = "+31624896641" ' Recipient's mobile number
objSmsMessage.Format = objConstants.asMESSAGFORMAT_UNICODE ' SMS message text
objSmsMessage.Data = "ملحق خاصملحق خاص" ' SMS message text

objGsmProtocol.Send( objSmsMessage )	
WScript.Echo "Result: " & objGsmProtocol.LastError

More samples

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

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