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.0  (6826 KB - .exe file)
  Download Manual  (623 KB - .htm file)


SMS Delivery Reports with SMPP protocol


There are two ways to verify the delivery of SMS messages.

  • Query the status of the message
  • Request delivery reports from the provider

Query the status of the message

When a message is send using the SMPP protocol, the provider returns a message reference.
Using this reference, we can query the provider for the delivery status of this message.
This is done by sending a 'query_sm' packet to the provider. If the message reference is known by the provider,
it responds with a 'query_sm_resp' packet. This packet holds the status of the message. This can be one of the following values:

Status Number Status Explanation
0 SCHEDULED The message is scheduled for later sending.
1 ENROUTE The message is enroute.
2 DELIVERED The message was successfully delivered.
3 EXPIRED The SMSC was unable to deliver the message in a specified amount of time.
For instance when the phone was turned off.
4 DELETED The message was deleted.
5 UNDELIVERABLE The SMS was unable to deliver the message.
For instance, when the number does not exist.
6 ACCEPTED The SMS was accepted and will be send.
7 UNKNOWN Unknown error occured.
8 REJECTED The message was rejected.
The provider could have blocked phonenumbers in this range.
9 SKIPPED The message was skipped.

The disadvantage of this method is, that you have to poll once in a while to get the current message status.
When a lot of messages are enroute for a couple of hours, this will cause heavy data traffic. Most providers recommend you to request delivery reports instead of querying, because there is only data sent by the provider when the status of a message has changed.


Request delivery reports from the provider

The best way to check the status of each message sent, is to ask for delivery reports.
This can be done by setting the 'registered_delivery' value of the 'submit_sm' packet.
This parameter can have one of the following values:

Value Meaning
0 Do not send delivery reports
1 Always send delivery reports
2 Send delivery report in case of an error
3 Send delivery report only when message is delivered

By setting this value to '1', the provider will send a delivery report to the client every time the status of this message changes.
You can set this value per message.

The delivery reports are sent to the client using the 'deliver_sm' packet. This is the same packet as used to deliver incoming messages.
To detect whether a 'deliver_sm' is a delivery report or a message, you have to check the 'esm_class' field. If bit 2 of this byte is set ( 0x04 ), it is a delivery report.
To use delivery reports, you have to setup a transceiver connection to the SMPP provider, because you are going to send and receive messages.
The delivery status is encoded in the 'short_message' field as an ASCII text message.
This format is product specific, but the following format is used by most SMPP providers:


id:c449ab9744f47b6af1879e49e75e4f40 sub:001 dlvrd:0 submit date:0610191018 done date:0610191018 stat:ACCEPTD err:0 text:This is an Acti
id:7220bb6bd0be98fa628de66590f80070 sub:001 dlvrd:1 submit date:0610190851 done date:0610190951 stat:DELIVRD err:0 text:This is an Acti
id:b756c4f97aa2e1e67377dffc5e2f7d9b sub:001 dlvrd:0 submit date:0610191211 done date:0610191211 stat:REJECTD err:1 text:This is an Acti
id:bd778cd76ae9e79da2ddc8188c68f8c1 sub:001 dlvrd:0 submit date:0610191533 done date:0610191539 stat:UNDELIV err:1 text:This is an Acti


Field Meaning
id The message reference of the message.
sub Sub-ID, not used.
dlvrd Value '1' when the message has been delivered, if the message is still pending '0'.
submit date Submission date and time.
done date Date and time the status has changed, or message delivery time when stat is set to 'DELIVRD'.
stat Current status of the message.
err Additional error code, provider specific.
text Part of the original message text.

When using SMPP version 3.4, sometimes the message has some optional parameters (TLV's) attached containing the message state, message reference and a network error code.
Please refer to the SMPP version 3.4 documentation on how to use these TLV's.


    Using delivery reports in the ActiveXperts SMS and MMS Toolkit


The SMS and MMS Toolkit supports both methods to retrieve the delivery status of a message.
We recommend to use the second method, because it causes less data traffic.

To use this method you have to connect with the 'SystemMode' property set to 'asSMPP_MODE_TRANSCEIVER'.
Because the connection is setup for both sending and receiving, the SMS component will be listening for incoming delivery reports and store them in its internal cache memory.

Once the connection has been established using the 'Connect' function, you can submit messages. If a message is accepted by the provider it will return the reference number for this message. This reference number is stored in the 'MessageReference' property.

To query the status of a message, you have to set the 'MessageReference' property first.
Now you can call the 'QueryStatus' function. The QueryStatus will check the internal cache of the SMS component if there is a delivery report available for the given message reference.
If the operation was successfull ( LastError = 0 ), the following properties will be set:

Poperty Meaning
StatusCode The status of the message. See the above table for possible values
StatusTime The last time the status has been changed, or the delivery time
StatusTimeSeconds The last time the status has been changed, or the delivery time, in seconds since 1-1-1970

You can use the 'GetStatusDescription' function to convert 'StatusCode' to a readable status.


The following VBScript code sample demonstrates how to use delivery reports with the SMS and MMS Toolkit:

Dim objSmpp
Dim objConstants
Dim strStatus
Dim strRef

Set objSmpp                 = CreateObject ( "ActiveXperts.Smpp" )
Set objConstants            = CreateObject ( "ActiveXperts.SmsConstants" )

objSmpp.Server              = "smpp.activexperts-labs.com"
objSmpp.SystemID            = "AX008"
objSmpp.SystemPassword      = "812056"

objSmpp.SystemMode          = objConstants.asSMPPMODE_TRANSCEIVER			' connect as Transceiver
objSmpp.SystemVersion       = objConstants.asSMPPVERSION_34				' use SMPP version 3.4

objSmpp.Connect

If ( objSmpp.LastError ) Then
    WScript.Echo  "Connect failed: " & objSmpp.GetErrorDescription ( objSmpp.LastError )
    WScript.Quit
End If

objSmpp.MessageData         = "delivery report test"
objSmpp.MessageRecipient    = "+31647134225"
objSmpp.RequestStatusReport = True

objSmpp.Send

If ( objSmpp.LastError ) Then
    WScript.Echo  "Send failed: " & objSmpp.GetErrorDescription ( objSmpp.LastError )
    objSmpp.Disconnect
    WScript.Quit
End If

strRef = objSmpp.MessageReference

WScript.Echo "Message submitted, ID = " & strRef							' Store message reference

For i = 1 To 20
    
    WScript.Sleep  5000  
    
    objSmpp.MessageReference = strRef								' Set message reference
    objSmpp.QueryStatus										' Query the delivery status
    
    strStatus = "Message status after " & i * 5 & " seconds: " & objSmpp.GetStatusDescription ( objSmpp.StatusCode )
    
    WScript.Echo strStatus
Next

objSmpp.Disconnect

WScript.Echo "Ready."

This VBScript will generate the following output:
Message submitted, ID = 00000E73

Message status after  5 seconds: Scheduled
Message status after 10 seconds: Enroute
Message status after 15 seconds: Enroute
Message status after 20 seconds: Enroute
Message status after 25 seconds: Enroute
Message status after 30 seconds: Enroute
Message status after 35 seconds: Enroute
Message status after 40 seconds: Enroute
Message status after 45 seconds: Enroute
Message status after 50 seconds: Enroute
Message status after 55 seconds: Enroute
Message status after 60 seconds: Enroute
Message status after 65 seconds: Enroute
Message status after 70 seconds: Enroute
Message status after 75 seconds: Enroute
Message status after 80 seconds: Enroute
Message status after 85 seconds: Enroute
Message status after 90 seconds: Enroute
Message status after 95 seconds: Enroute
Message status after 100 seconds: Delivered
Ready.
Ready.
To use the first method (querying the provider), justy replace the 'objSmpp.RequestStatusReport = True' with 'objSmpp.RequestStatusReport = False'.




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.