0% found this document useful (0 votes)
488 views

Send SMS Messages Using Delphi and SMS Messaging Server

This document provides steps to create an SMS message using the ActiveXperts SMS Messaging Server API in Delphi. It includes downloading and installing the SMS Messaging Server, creating a Delphi project, adding references to the SMS Messaging Server library, declaring objects, creating an SMS message object, setting message properties, and saving the message to the database. The full source code for an example program is also provided.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
488 views

Send SMS Messages Using Delphi and SMS Messaging Server

This document provides steps to create an SMS message using the ActiveXperts SMS Messaging Server API in Delphi. It includes downloading and installing the SMS Messaging Server, creating a Delphi project, adding references to the SMS Messaging Server library, declaring objects, creating an SMS message object, setting message properties, and saving the message to the database. The full source code for an example program is also provided.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ActiveXperts » SMS Messaging Server » How to create a new Message » SMS » Delphi

ON 1/1/2020, AURON SOFTWARE B.V. ACQUIRED ACTIVEXPERTS SMS MESSAGING SERVER AND WILL CONTINUE
DEVELOPING, SELLING AND SUPPORTING THE PRODUCT UNDER IT'S OWN BRAND NAME AURON SMS SERVER.
MAINTENANCE CONTRACTS WILL BE CONTINUED DIRECTLY BY AURON SOFTWARE AS OF 1/1/2020.

CREATE AN SMS MESSAGE USING THE SMS MESSAGING SERVER API - DELPHI

Introduction

In this example we are going to create a Delphi sample page to create an SMS using the ActiveXperts SMS Messaging Server API. The SMS Messaging Server service will send
the message you created in the database.

Step 1: Download and install SMS Messaging Server

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

Step 2: Create a new Delphi Project

Launch Borland Delphi from the Start menu. In our example we use Delphi 2010. Choose 'New' from the 'File' menu and select your preferred kind of application, for instance: 'VCL
Forms Application - Delphi'. A new Form is displayed in the workspace.

(Click on the picture to enlarge)

Step 3: Refer to the SMS Messaging Server Library and create the objects

Now that a new project has been created, you must add a reference to the SMS Messaging Server Library in the project to be able to use the SMS Messaging Server objects. To
do so, choose 'Import Component...' from the 'Component' menu. The Import Components' dialog appears. Select 'Import a Type Library':
(Click on the picture to enlarge)

In the 'Registered Type Libraries' page, select 'ActiveXperts SMS Messaging Server Type Library' and click 'Next':

(Click on the picture to enlarge)

In the 'Components' page, leave all fields default and click 'Next':
(Click on the picture to enlarge)

In the 'Install' page, select 'Create Unit' and click 'Next':

(Click on the picture to enlarge)

The interface code is generated now and is shown in the AXMMCFGLib_TLB tab of the project.

Step 4: Declare and create the object

From the Project Manager, open Unit1.bas and add the AXMMCFGLib_TLB to the 'Uses' statement to refer to the SMS Messaging Server Library:
(Click on the picture to enlarge)

In the 'private' or 'public' section, declare the following objects:

objMessageDB : IXMessageDB;
objConstants : IXConstants;

You can now create the objects, for instance in the 'FormCreate' function:

objMessageDB := CoXMessageDB.Create();
objConstants := CoXConstants.Create();

Step 5: Create the SMS Message

The following code will create the SMS Message.

// Create a new message


objMessage := IDispatch (objMessageDb.Create()) as IXMessage;
Writeln('Create message result: ', InttoStr(objMessageDb.LastError), ' ',
objMessageDb.GetErrorDescription(objMessageDb.LastError));
if (objMessageDb.LastError <> 0) then
begin
objMessageDb.Close();
Exit;
end;

Step 6: Save the SMS Message

The following code will save the SMS message into the database:

// Save the message to the message database


vt := objMessage;
objMessageDB.Save (vt);
Writeln('Save result: ', InttoStr(objMessageDb.LastError), ' ',
objMessageDb.GetErrorDescription(objMessageDb.LastError));

Appendix: Full source code

The following code shows how to send an SMS message using the SMS Messaging Server API:
{******************************************************************************}
{ }
{ ActiveXperts }
{ }
{ SMS Messaging Server: create SMS }
{ }
{******************************************************************************}
program CreateEMAIL;

{$APPTYPE CONSOLE}

uses
SysUtils, ActiveX,
AXMMCFGLib_TLB in '..\typelib-imports\AXMMCFGLib_TLB.pas';

{= V A R I A B L E S ==========================================================}
var
objMessageDb : XMessageDB;
objConstants : XConstants;
strRecipient, strBody:string;
objMessage: XMessage;
vt:OleVariant;

{= P R O G R A M ==============================================================}
begin
// Create API objects
objMessageDB := CoXMessageDB.Create();
objConstants := CoXConstants.Create();

// Open message database


objMessageDb.Open(True);
Writeln('Open result: ', InttoStr(objMessageDb.LastError), ' ',
objMessageDb.GetErrorDescription(objMessageDb.LastError));
if (objMessageDb.LastError <> 0) then Exit;

// Get message info from user


Writeln('Enter recipient''s phone number: ');
Readln(strRecipient);
Writeln('Enter body of the message:');
Readln(strBody);

// Create a new message


objMessage := IDispatch (objMessageDb.Create()) as IXMessage;
Writeln('Create message result: ', InttoStr(objMessageDb.LastError), ' ',
objMessageDb.GetErrorDescription(objMessageDb.LastError));
if (objMessageDb.LastError <> 0) then
begin
objMessageDb.Close();
Exit;
end;

// Set the properties for the message object


Writeln('RecordID: ',objMessage.ID);
objMessage.DirectionID := objConstants.MESSAGEDIRECTION_OUT;
objMessage.typeID := objConstants.MESSAGETYPE_SMS;
objMessage.StatusID := objConstants.MESSAGESTATUS_PENDING;
objMessage.ChannelID := 0;
objMessage.ScheduledTime := '';
objMessage.ToAddress := strRecipient;
objMessage.Body := strBody;

// Save the message to the message database


vt := objMessage;
objMessageDB.Save (vt);
Writeln('Save result: ', InttoStr(objMessageDb.LastError), ' ',
objMessageDb.GetErrorDescription(objMessageDb.LastError));

// Close message database


objMessageDB.Close;
write('Press ENTER to close the program');
readln;
end.

You might also like