ActiveXperts
SMS & MMS Toolkit


 Product Overview

 Supported Protocols:
 
 How to use

 Online Samples

 Download (.exe)

 Brochure (.pdf)

 Manual (.htm)

 Release Notes


Support

 Knowledge Base

 Forum

 Contact Support


Purchase

 Licensing

 Pricing

 Order now


Providers

 SMPP Providers

 MMS Providers

 TAP/UCP Providers

 SNPP Providers


Related documents

 Case studies

 SMS Documents

 GSM Network Codes

 TAPI Documents

 About Mobile
 Communications


 AT Commands

 RFC's


  Download ActiveXperts SMS and MMS Toolkit 5.1  (6826 KB - .exe file)
  Download Manual  (623 KB - .htm file)


Using the SMS and MMS Toolkit with Visual C++ 5.x/6.x (MM1 Connection)


The SMS and MMS Toolkit is a software development kit (SDK) to enhance an application or script with SMS, MMS and Pager functionality.
An 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.
An 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 Chinese, Turkisch, 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, 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 C++ 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':

    
    (Click on the picture to enlarge)

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

    
    (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\xmstoolkit\Examples\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:
    IMmsProtocolMm1  *m_pConnection    = NULL;
    IMmsMessage      *m_pMessage       = NULL;
    IMmsSlide        *m_pSlide         = 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_MmsProtocolMm1, NULL, CLSCTX_INPROC_SERVER, IID_IMmsProtocolMm1, (void**) &m_pConnection );

There is no need to create the MmsMessage and MmsSlide object, because they are retrieved from the MmsProtocolMm1 object while receiving the messages.

Step 5: Send MMS messages

You can now receive MMS messages using a connected GSM GPRS/EDGE/UMTS modem.

The following code shows how to receive MMS messages using C++ :
#include <windows.h>
#include <stdio.h>
#include <comdef.h>
#include <atlbase.h>

///////////////////////////////////////////////////////////////////////////////////////////

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

///////////////////////////////////////////////////////////////////////////////////////////

LPSTR ReadInput( LPCSTR lpszTitle, BOOL bAllowEmpty = FALSE );
void ReadMm1Provider( IMmsProtocolMm1 *pMm1Protocol );

LPSTR AskDevice( IMmsProtocolMm1 *pMm1Protocol );
LPSTR GetErrorDescription( LONG lLastError, IMmsProtocolMm1 *pMm1Protocol );

///////////////////////////////////////////////////////////////////////////////////////////

int main(int argc, char* argv[])
{
	IMmsProtocolMm1     *pMm1Protocol		= NULL;
	IMmsSlide			*pSlide				= NULL;
	IMmsMessage			*pMessage			= NULL;

	LPSTR				lpszPincode			= NULL;

	HRESULT				hr;

	LONG				lLastError;
	LONG				lCount;
	LONG				l;

	BSTR				bstrTemp			= NULL;

	VARIANT				vtVarMsg;
	VARIANT				vtVarSld;

	// Initialize COM  
	CoInitialize(NULL);

	// Initialize Variants
	VariantInit ( &vtVarMsg );
	VariantInit ( &vtVarSld );

	// Create object
	hr = CoCreateInstance(CLSID_MmsProtocolMm1, NULL, CLSCTX_INPROC_SERVER, IID_IMmsProtocolMm1, (void**) &pMm1Protocol);

	if( ! SUCCEEDED( hr ) )
	{
		printf( "Unable to create MmsProtocolMm1 object.\n" );
		goto _EndMain;
	}

	// MmsProtocolMm1: Clear
	pMm1Protocol->Clear();

	// MmsProtocolMm1: Device property
	pMm1Protocol->put_Device( _bstr_t( AskDevice( pMm1Protocol ) ) );

	// MmsProtocolMm1: PIN code
	lpszPincode = ReadInput( "Enter PIN code (leave blank for no PIN code)", TRUE );
	if( strlen( lpszPincode ) > 0 )
	{
		printf( "Passing PIN code...\n" );
		pMm1Protocol->EnterPin( _bstr_t( lpszPincode ) );
		pMm1Protocol->get_LastError( &lLastError );
		printf( "EnterPin, result: %ld (%s)\n\n", lLastError, GetErrorDescription( lLastError, pMm1Protocol ) );
	}

	// MmsProtocolMm1: properties
	pMm1Protocol->put_ProviderMMSC( _bstr_t( ReadInput( "Enter MMSC IP/host address" ) ) );
	pMm1Protocol->put_ProviderAPN( _bstr_t( ReadInput( "Enter APN" ) ) );
	pMm1Protocol->put_ProviderAPNAccount( _bstr_t( ReadInput( "Enter APN Account (optional)", TRUE ) ) );
	pMm1Protocol->put_ProviderAPNPassword( _bstr_t( ReadInput( "Enter APN Password (optional)", TRUE ) ) );
	pMm1Protocol->put_ProviderWAPGateway( _bstr_t( ReadInput( "Enter WAP Gateway" ) ) );

	// MmsProtocolMm1: CountReceivedMessages
	printf ( "Checking for new MMS messages...\n" );
	pMm1Protocol->CountReceivedMessages ( &lCount );
	pMm1Protocol->get_LastError ( &lLastError );
	printf ( "CountReceivedMessages, result: %ld (%ls)\n\n", lLastError, GetErrorDescription ( lLastError, pMm1Protocol ) );
	if ( lLastError != 0L )
		goto _EndMain;

	printf ( "Number of new messages waiting on MMSC: %ld\n\n", lCount );

	if ( lCount == 0L )
		goto _EndMain;

	// MmsProtocolMm1: Connect
	printf( "Connecting...\n" );
	pMm1Protocol->Connect();
	pMm1Protocol->get_LastError( &lLastError );
	printf( "Connect, result: %ld (%s)\n\n", lLastError, GetErrorDescription( lLastError, pMm1Protocol ) );
	if( lLastError != 0L )
		goto _EndMain;

	// MmsProtocolMm1: Receive Messages
	for ( l = 0 ; l < lCount ; l++ )
	{
		pMm1Protocol->GetMessage ( l, &vtVarMsg );
		pMm1Protocol->get_LastError ( &lLastError );
		printf( "GetMessage (%ld), result: %ld (%s)\n\n", l, lLastError, GetErrorDescription( lLastError, pMm1Protocol ) );

		if ( lLastError != 0L )
			goto _EndMain;

		pMessage = ( IMmsMessage * ) vtVarMsg.pdispVal;

		if ( pMessage )
		{
			// Get Sender Address
			pMessage->get_From ( &bstrTemp );
			printf ( "New MMS message received from: %ls\n", bstrTemp );
			SysFreeString ( bstrTemp );

			// Get first slide
			pMessage->GetFirstSlide ( &vtVarSld );

			pSlide = ( IMmsSlide * ) vtVarSld.pdispVal;

			if ( pSlide )
			{
				LONG lAttachments = 0L, k = 0L;

				// Count attachments
				pSlide->CountAttachments ( &lAttachments );
					
				// Display attachment filenames
				for ( k = 0 ; l < lAttachments ; k++ )
				{
					pSlide->GetAttachmentName ( k, &bstrTemp );
					printf ( "Attachment #%ld: %ls\n", k, bstrTemp );
					SysFreeString ( bstrTemp );
				}
			
				VariantClear ( &vtVarSld );
			}

			VariantClear ( &vtVarMsg );
		}
	}

_EndMain:

	if( pMm1Protocol != NULL ) 
	{
		// MmsProtocolMm1: Disconnect
		pMm1Protocol->Disconnect();
		pMm1Protocol->Release();
	}

	if( pMessage != NULL ) 
		pMessage->Release();

	if( pSlide != NULL ) 
		pSlide->Release();

	CoUninitialize();

	printf("Ready.\n");

	return 0;
}

///////////////////////////////////////////////////////////////////////////////////////////

LPSTR ReadInput( LPCSTR lpszTitle, BOOL bAllowEmpty )
{
	static CHAR		szInput [ 255 + 1 ] = { 0 };

	printf ( "%s:\n", lpszTitle );
	do
	{
		printf ( "   > " );
		// scanf ( "%s", szInput );
		fflush(stdin); 
		fflush(stdout); 
		fgets( szInput, 255, stdin );
		if( szInput[ 0 ] != '\0' && szInput[ strlen( szInput ) - 1  ] == '\n' )
			szInput[ strlen( szInput ) - 1  ] = '\0';
	} while( lstrlen ( szInput ) == 0 && ! bAllowEmpty );
	printf( "\n" );

	return szInput;
}

///////////////////////////////////////////////////////////////////////////////////////////

LPSTR AskDevice( IMmsProtocolMm1 *pMm1Protocol )
{
	LONG		lDeviceCount		= 0L;
	LONG		lDevice				= 0L;
	static CHAR	szDevice[ 256 + 1 ]	= { 0 };

	pMm1Protocol->GetDeviceCount ( &lDeviceCount );

	printf ( "Select a device:\n" );

	for ( int j = 0 ; j < lDeviceCount ; j++ )
	{
		BSTR	bstrTemp = NULL;
		pMm1Protocol->GetDevice ( j, &bstrTemp );
		printf ( "   %ld: %ls\n", j, bstrTemp );
		SysFreeString( bstrTemp );
	}

	while ( lDevice == 0L )
	{
		printf ( "   > " );
		scanf ( "%d", &lDevice );
		if( lDevice < j ) 
		{
			BSTR	bstrDevice = NULL;
			pMm1Protocol->GetDevice ( lDevice, &bstrDevice );
			sprintf ( szDevice, "%ls", bstrDevice );
			SysFreeString( bstrDevice );
		}
		else
		{
			lDevice = 0L;
		}
	}
	printf ( "  Selected device: %s\n\n", szDevice );
	return szDevice;
}



///////////////////////////////////////////////////////////////////////////////////////////

LPSTR GetErrorDescription( LONG lLastError, IMmsProtocolMm1 *pMm1Protocol )
{
	static CHAR		szErrorDescription[ 1024 + 1 ] = { 0 };
	BSTR			bstrErrDescr = NULL;

	szErrorDescription[ 0 ] = '\0';
	pMm1Protocol->GetErrorDescription( lLastError, &bstrErrDescr );
	if( bstrErrDescr != NULL )
	{
		sprintf( szErrorDescription, "%ls", bstrErrDescr );
		SysFreeString ( bstrErrDescr );

	}
	return szErrorDescription;
}


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





The ActiveXperts SMS and MMS Toolkit is a SMS development component (SDK). This control can be used by any Windows development platform, including Visual Basic .NET, Visual CSharp .NET, ASP .NET (VB,CS), ASP, Visual Basic, Visual Basic for Applications (VBA), Visual Studio/Visual C++, Borland Delphi and C++ Builder, PHP, ColdFusion, HTML, VBScript and any other ActiveX/COM compliant platform. The SMS and MMS Toolkit is an ActiveXperts Software B.V. Product.

Copyright ©1999-2007 ActiveXperts Software. All rights reserved.