ActiveXperts SMS Component


Powershell sample - Send SMS text through an HTTP provider

The ActiveXperts SMS Component is a software development kit (SDK) to enhance an application or script with SMS or Pager functionality. SMS messages can be sent/received using a GSM modem, an SMPP provider or an HTTP compliant SMSC.


In this example we are going to create a Powershell page named 'Demo.ps1' to send SMS messges. This demo project will ask the user to give a phone number and a message body in the web interface.

A subscription to an HTTP provider is required. For this demo you can send a limited number of messages through our own gateway.

Step 1: Download and install The ActiveXperts SMS Component

Download the ActiveXperts SMS Component from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Create a new script

Create a new script using your favorite editor. You can simply use notepad. However, a Powershell editor is recommended, so you can browse through objects, objects properties and object functions.

You're now able to write a more advanced Powershell script to send SMS messages using the ActiveXperts SMS Component.

Step 3: Create the ActiveXperts SMS Component objects in Powershell

Create a new Powershell file called DEMO.PS1.

Create the objects like this:

$objHttp          = new-object -comobject AxSms.Http
$objMessage       = new-object -comobject AxSms.Message
$objConstants     = new-object -comobject AxSms.Constants

Now, add the following lines to the file to have your fist SMS Component VBScript program:

Write-Host "ActiveXperts SMS Component " $objHttp.Version " demo."
Write-Host "License Status: " $objHttp.LicenseStatus "`r`n"

Step 4: Send SMS messages

The following code shows how to send an SMS message using the data that was stored in the 'objSmsMessage' and 'objSmsConstants' objects.

$strResult = $objHttp.SendSms($objMessage)
write-host $strResult
$strResult = "SendSms, result: " + $objHttp.LastError + " (" + 

Appendix: Full source code

Following you can find the full source code which is also included in the ActiveXperts SMS Component package.


$objHttp = new-object -comobject AxSms.Http
$objMessage = new-object -comobject AxSms.Message
$objSmsConstants = new-object -comobject AxSms.Constants

# Display SMS Component Version
write-host "SMS Component Version" $objHttp.Version "; 
Build" $objHttp.Build "; Module" $objHttp.Module

# Display if the ActiveXperts SMS Component is registered.
write-host "License Status:" $objHttp.LicenseStatus
write-host ""

# Set Logfile
$objHttp.Logfile = $env:temp + "\HTTP_sendsms_text.txt"
write-host "Log file can be found here:"
write-host $objHttp.Logfile
write-host ""

$strSystemID = "mySystemID"
$strPassword = "myPassword"

$objHttp.Url = "" + 
$strSystemID + "&password=" + $strPassword + "&text=" + 

$objMessage.BodyFormat = $objSmsConstants.GSM_MESSAGEFORMAT_TEXT
$objMessage.ToAddress =  "+31611223344"
$objMessage.Body = "This is a test message!" 
"Hello, world!" $False

$strResult = $objHttp.SendSms($objMessage)
write-host $strResult
$strResult = "SendSms, result: " + $objHttp.LastError + " (" + 
$objHttp.GetErrorDescription($objHttp.LastError) + ")"
write-host $strResult
write-host "Response:"$objHttp.LastResponseCode

write-host "Ready."

To run the code, start Powershell and browse to the location of the file you just created. Enter .\Demo.ps1 to run the code. Notice that if the script is not working, you have to change the execution policy; you can do that with the following command:

Set-ExecutionPolicy -unrestricted

You can download the full source code of this project from the ActiveXperts FTP site: There are many other working samples included with the product or on the FTP site.

NOTE: Demo Projects are created with Microsoft Visual Studio 2008

The ActiveXperts SMS Component project ships with a set of Microsoft Visual Studio .NET samples. The projects are created with Microsoft Visual Studio 2008.

Users with a later version of Microsoft Visual Studio can open such a project. The Visual Studio Conversion Wizard will guide you through the process of converting the project to the version used.