Download ActiveXperts SMS Messaging Server 4.1  (5828 KB - .exe file)
Send an SMS message using the SMS Messaging Server API Borland Delphi
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:
- Mobile users query a database; results are sent back via SMS or e-mail;
- Mobile users receive important information via SMS or e-mail while they are away from the office;
- Stock prices are sent automatically via SMS and/or e-mail, daily;
- Remote workers can update their worksheet from a remote location trough SMS;
- ICT administrators restart/reboot servers and/or daemons from remote by SMS;
- Setup an SMS voting system, supporting SMS and/or e-mail;
- Etc.
SMS Messaging Server can be well integrated into VBScript environments.
This document describes how the SMS Messaging Server can be integrated into VBScript projects.
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 (for instance 'Delphi 2005') from the Start menu.
Choose 'New' from the 'File' menu and select your preferred kind of application, for instance: 'VCL Forms Application - Delphi for Win32'.
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 AxSmsCfg_TLB tab of the project.
Step 4: Declare and create the object
From the Project Manager, open Unit1.bas and add the AxSmsCfg_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 := TXMessageDB.Create(Form1).DefaultInterface;
objConstants := TXConstants.Create(Form1).DefaultInterface;
Step 5: Send an SMS Message
The following code shows how to send an SMS message:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, AXSMSCFGLib_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 ();
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.
ActiveXperts SMS Messaging Server is a messaging framework to send and receive email and SMS messages.
Use the API to create new messages from various development platforms,
including Visual Basic .NET, Visual CSharp .NET,
ASP .NET (VB,CS),
ASP,
Visual Basic,
Visual Studio/Visual C++,
Delphi,
PHP,
HTML,
VBScript and any other ActiveX/COM compliant platform. SMS Messaging Server is an ActiveXperts Software B.V. Product.
|