Quicklinks
SMS Messaging Server is an SMS messaging framework that enables companies to send, receive and process SMS- and e-mail messages. The framework is designed support virtually any scenario where low-and high volume SMS messaging is required. Use SMS Messaging Server in the following scenarios:
SMS Messaging Server can be well integrated into VBScript environments. This document describes how the SMS Messaging Server can be integrated into VBScript projects.
Download ActiveXperts SMS Messaging Server from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
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)
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.
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();
The following code shows how to send an SMS message:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AXMMCFGLib_TLB, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
ComboType: TComboBox;
EditRecipient: TEdit;
EditSubject: TEdit;
EditBody: TEdit;
ButtonCreate: TButton;
Label5: TLabel;
EditResult: TEdit;
procedure ComboTypeChange(Sender: TObject);
procedure ButtonCreateClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ShowResult (func : string);
private
objMessageDB : IXMessageDB;
objConstants : IXConstants;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
objMessageDB := TXMessageDB.Create(Form1).DefaultInterface;
objConstants := TXConstants.Create(Form1).DefaultInterface;
ComboType.Items.Add('SMS');
ComboType.Items.Add('E-mail')
end;
procedure TForm1.ButtonCreateClick(Sender: TObject);
var objMessage : IXMessage;
var vtVar : OleVariant;
begin
objMessageDB.Open (True);
ShowResult ( 'Open' );
if ( objMessageDB.LastError = 0 ) then begin
objMessage := IDispatch ( objMessageDB.Create () ) as IXMessage;
ShowResult ( 'Create' );
if ( objMessageDB.LastError = 0 ) then begin
objMessage.Direction := objConstants.MESSAGEDIRECTION_OUT;
objMessage.Status := objCOnstants.MESSAGESTATUS_PENDING;
objMessage.ChannelID := 0;
objMessage.ScheduledTime := '';
objMessage.Recipient := EditRecipient.Text;
objMessage.Subject := EditSubject.Text;
objMessage.Body := EditBody.Text;
{ NOTE: The 'Type' property is renamed to 'type_' to avoid conflicts with existing keywords. }
if ( ComboType.ItemIndex = 0) Then objMessage.type_ := objConstants.MESSAGETYPE_SMS;
if ( ComboType.ItemIndex = 1) Then objMessage.type_ := objConstants.MESSAGETYPE_EMAIL;
vtVar := objMessage;
objMessageDB.Save ( vtVar) ;
ShowResult ( 'Save' );
end;
end;
end;
procedure TForm1.ShowResult (func : String);
begin
EditResult.Text := func + ' : ERROR ' + IntToStr ( objMessageDB.LastError ) + ' (' +objMessageDB.GetErrorDescription(objMessageDB.LastError) + ')';
end;
procedure TForm1.ComboTypeChange(Sender: TObject);
begin
if ( ComboType.ItemIndex = 0) Then EditSubject.Enabled := False;
if ( ComboType.ItemIndex = 1) Then EditSubject.Enabled := True;
end;
end.