You are here:
ActiveXperts.com > SMS and MMS Toolkit > How to Use the SMS and MMS Toolkit > HTTP/SMS > Borland C++ Builder
Quicklinks
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:
MMS features:
Pager features:
This document describes how the SMS and MMS Toolkit can be integrated into Borland C++ Buider projects.
Download the SMS and MMS Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
Launch Borland C++ Builder (for instance 'Borland C++ Builder 6') from the Start menu. Choose 'New' from the 'File' menu and select 'Application'. A new Form is displayed in the workspace.
(Click on the picture to enlarge)
Now that a new project has been created, you must add a reference to SMS and MMS Toolkit in the project to be able to use the SMS and MMS Toolkit object. To do so, choose 'Import Type Library...' from the 'Project' menu. The Import Type Library' dialog appears.
(Click on the picture to enlarge)
In the upper selection box, select 'SMS and MMS Toolkit Type Library' and click 'Create Unit':
The interface code is generated now and is shown in the AXmsCtrl_TLB.cpp and AXmsCtrl_TLB.h tab of the project.
From the Project Manager, open Unit1.h and add include the AXmsCtrl_TLB.h file to refer to the SMS and MMS Toolkit library:
(Click on the picture to enlarge)
In the 'private' or 'public' section, declare the following objects:
TCOMISmsProtocolHttp m_objHttpProtocol; TCOMISmsMessage m_objSmsMessage;
You can now create the objects, for instance in the 'FormCreate' event handler or the class constructor:
m_objHttpProtocol = CoSmsProtocolHttp::Create (); m_objSmsMessage = CoSmsSmsMessage::Create ();
You can now send SMS messages.
The following code shows how to send an SMS message through an HTTP POST connection:
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { m_objHttpProtocol = CoSmsProtocolHttp::Create (); m_objSmsMessage = CoSmsMessage::Create (); } //--------------------------------------------------------------------------- void __fastcall TForm1::ButtonSendClick(TObject *Sender) { // Clear all properties m_objHttpProtocol->Clear(); // Set Logfile m_objHttpProtocol->set_LogFile(WideString (EditLogfile->Text)); // Set Provider properties m_objHttpProtocol->set_ProviderHost(WideString ( EditHostName->Text ) ); m_objHttpProtocol->set_ProviderPort(EditHostPort->Text.ToInt()); // Set URL template m_objHttpProtocol->set_URLText(WideString (EditURLText->Text) ); // Set Expected Response m_objHttpProtocol->set_ProviderSuccessResponse(WideString(EditSuccessResponse->Text)); // Set Message Properties m_objSmsMessage->set_Data(WideString(MemoMessage->Text)); m_objSmsMessage->set_Sender(WideString(EditSender->Text)); m_objSmsMessage->set_Recipient(WideString(EditRecipient->Text)); ButtonSend->Enabled = FALSE; Cursor = crHourGlass; // Send the message m_objHttpProtocol->Send( m_objSmsMessage ); Cursor = crDefault; ButtonSend->Enabled = TRUE; EditResult->Text = m_objHttpProtocol->GetErrorDescription(m_objHttpProtocol->LastError); EditLastResponse->Text = m_objHttpProtocol->get_ProviderResponse(); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { CHAR szTemp [ MAX_PATH + 1 ]; GetTempPath ( MAX_PATH, szTemp ); strcat ( szTemp, "SmsProtocolHttp.log" ); EditLogfile->Text = szTemp; } //--------------------------------------------------------------------------- void __fastcall TForm1::ButtonViewClick(TObject *Sender) { if ( EditLogfile->Text.Length() ) { ShellExecute ( NULL, _T("open"), EditLogfile->Text.c_str(), NULL, NULL, SW_SHOWDEFAULT ); } } //---------------------------------------------------------------------------
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.
The SMS and MMS Toolkit project ships with a set of samples for Borland C++ Builder. The projects are created with Borland C++ Builder 6.
Users with a later version of Borland C++ Builder 6 can open such a project. The Borland Conversion Wizard will guide you through the process of converting the project to the version used.