ActiveXperts SMS and MMS Toolkit Add SMS and MMS capabilities to any Windows or .NET application

Using the SMS and MMS Toolkit with Visual C++ 5.x/6.x

The SMS and MMS Toolkit is a software development kit (SDK) to enhance an application or script with SMS, MMS and Pager functionality. SMS messages can be sent using a GSM/GPRS modem, an SMPP provider, an HTTP compliant SMS provider or using a standard dialup or fixed-line SMS modem. MMS messages can be sent via a GSM/GPRS modem (MM1), an SMTP server (MM4) or an XML/SOAP compliant provider (MM7).

SMS features:

  • Send and receive numeric- and alphanumeric text SMS messages
  • Verify delivery of outgoing SMS messages
  • Support for multimedia SMS messages, including ringtones, pictures and logo's
  • Support for WAP Push, WAP Bookmarks, vCards, voicemail/e-mail/fax/MMS indications
  • Support for Unicode, to support foreign languages like Arabic, Chinese, Hebrew, etc.
  • Support for multi-part messages, to allow messages longer than 160 characters
  • Support for GSM modems, GSM phones, SMS/HTTP providers, SMPP (Short Message Peer to Peer) providers, TAP/XIO and UCP dial-in SMSC providers
  • Support Multi-threading environments. The component is thread-safe, which means it can be used in a multi-threaded environment
  • Samples included for various development platforms: MS Visual Basic, MS Visual Basic .NET, MS Visual C++, MS Visual Studio C# .NET, ASP, ASP .NET, Borland Delphi, Borland C++ Builder, Windows Powershell ColdFusion and more

MMS features:

  • Support for many multimedia formats incl.: JPG, GIF, PNG, BMP, WBMP, TIF, WAV, MP3, MIDI, AC3, GP3, AVI, MPG, MP4, VCARD, VCALENDAR, JAR and more
  • Support for MM1 (MMS over WAP), MM4 (MMS over SMTP) and MM7 (MMS over HTML/SOAP)

Pager features:

  • Send alpha-numeric Pager messages through SNPP

This document describes how the SMS and MMS Toolkit can be integrated into Visual Studio C++ 5.x/6.x projects.

Step 1: Download and install the SMS and MMS Toolkit

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

Step 2: Create a new Visual C++ project

Launch 'Microsoft Visual C++' from the Start menu, and choose 'New' from the 'File Menu'. The 'New' dialog appears.

Select the type of project (for instance: 'Win32 Console Application'), enter a 'Project name' and select the 'Location':

Visual C

(Click on the picture to enlarge)

Select the kind of project, for instance a 'Hello, world!' application and click 'Finish':

Visual C

(Click on the picture to enlarge)

A new Project is created now.

Step 3: Refer to the SMS and MMS Toolkit Library

Before you can use the SMS and MMS Toolkit, you need to refer to the SMS and MMS Toolkit library. The actually reference files are shipped with the product and are located in the following directory:

C:\Program Files\ActiveXperts\SMS and MMS Toolkit\Samples\Visual C++\Include

Copy all files in the above directory ('AXmsCtrl.h', 'AXmsCtrl_i.c' and 'AXmsConstants.h') to your project directory.

Step 4: Declare and create the SMS and MMS Toolkit objects

On top of your code, declare the following objects:

ISmsProtocolGsm    *pGsmProtocol    = NULL;
ISmsMessage        *pSmsMessage     = NULL;

Since the SMS and MMS Toolkit is a COM object, you must initialize the COM library before they can call COM library functions (e.g. SMS and MMS Toolkit functions):

CoInitialize(NULL);

Create the GSM objects in the following way:

CoCreateInstance( CLSID_SmsProtocolGsm, NULL, CLSCTX_INPROC_SERVER, IID_ISmsProtocolGsm, (void**) &pGsmProtocol);
CoCreateInstance( CLSID_SmsMessage  , NULL, CLSCTX_INPROC_SERVER, IID_ISmsMessage,  (void**) &pSmsMessage );

Step 5: Send and/or receive SMS messages

You can now send and/or receive SMS messages.

The following code shows how to send a SMS message using a connected GSM phone or modem:

#include <comdef.h>
#include <atlbase.h>
#include <windows.h>
#include <stdio.h>

#include "..\..\include\aXmsConstants.h"
#include "..\..\include\aXmsCtrl.h"
#include "..\..\include\aXmsCtrl_i.c"


int main(int argc, char* argv[])
{
   ISmsProtocolGsm *pSmsProtocol   = NULL;
   ISmsMessage     *pSmsMessage    = NULL;	
   LONG            lLastError      = 0L;
   HRESULT         hr              = S_OK;
   _bstr_t         bstrRecipient   = "+31647134225";
   _bstr_t         bstrMessage     = "Hello, how are you?";
   _bstr_t         bstrLogFile     = "c:\\smslog.txt";
   _bstr_t         bstrDevice      = "COM1";
   BSTR            bstrMessageRef  = NULL;
	
   // initialize COM
   
   CoInitialize(NULL);

   CoCreateInstance(CLSID_SmsProtocolGsm, NULL, CLSCTX_INPROC_SERVER, IID_ISmsProtocolGsm, (void**) &pSmsProtocol );
   CoCreateInstance(CLSID_SmsMessage, NULL, CLSCTX_INPROC_SERVER, IID_ISmsMessage, (void**) &pSmsMessage );

   pSmsProtocol->put_Device                ( bstrDevice );           // Comport or TAPI Device
   pSmsProtocol->put_LogFile               ( bstrLogFile );          // Set logfile (not required)

   pMessage->put_Recipient                 ( bstrRecipient );        // Recipient
   pMessage->put_Data                      ( bstrMessage );          // Message body 
   pMessage->put_Format                    ( asMESSAGEFORMAT_TEXT ); // Textmessage

   printf( "Sending SMS message through GSM...\n" );

   pSmsProtocol->Send( &_variant_t ( ( IDispatch*) pMessage ), &bstrMessageRef );

   pSmsProtocol->get_LastError( &lLastError );
	
   printf ( "Send, result: %ld\n" , lLastError );

_EndMain:

   pSmsProtocol->Release();
   pSmsMessage->Release();

   if( bstrMessageRef != NULL )
      SysFreeString ( bstrTemp );

   CoUninitialize();

   return 0;
}

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/mobile-messaging-component.