Smart Messaging® Edition - Code samples

 

We have included some source code examples to show you how the SDK is used to encode and decode SMS content.

 

Here is an example for creating (encoding) the PDU strings for a Picture Message:

 

Visual Basic

C++

VB.NET

C#

Dim objEncoder As New SMSEngineLib.SMSMessageManager
Dim objPictureMessage As SMSEngineLib.PictureMessage
Dim objPDU As SMSEngineLib.PDU

'Create a new picture message
Set objPictureMessage = objEncoder.CreatePictureMessage( _
         "", _
         "Please call me ASAP", _
         "c:\temp\PicMsg.bmp")

'Iterate through PDUs collection for results
For Each objPDU In objPictureMessage .PDUs
    Debug.Print "PDU to send: " + objPDU.PDU
    Debug.Print "Length in octets (use with AT+CMGS): " + CStr(objPDU.LengthInOctets)
Next

Here is an example for decoding the PDU strings for a Picture Message:

 

 

Visual Basic C++ VB.NET C#

Dim objDecoder As New SMSEngineLib.SMSMessageManager
Dim objSMSMessage As SMSEngineLib.SMSMessage
Dim objPictureMessage As SMSEngineLib.PictureMessage
Dim objPDU As SMSEngineLib.PDU

'Decode the incoming PDU
Set objSMSMessage = objDecoder.DecodePDU( _
    "F2440BF100F" & _
    "521448AE" & _
    "C00060000C1B031F00C00660000C" & _
    "1B033181EE1EF6C33C" & _
    "66C3661C3CF1CE1C3CFB" & _
    "0183F30663C606337B31861B3661866C1B33318619E3618" & _
    "3CC1B331F000000000000000000")

'Do we have the complete PDU?
If objSMSMessage.State = Waiting Then Exit Sub 'Come back later with the next PDU

If objSMSMessage.MessageType = PictureMessage Then

    'Cast to a PictureMessage message to get specific properties
    Set objPictureMessage = objSMSMessage

    'Report on some of the incoming message properties
    Debug.Print "Image for Picture Message: " + objPictureMessage.BitmapFileName
    Debug.Print "Sent from: " + objPictureMessage.SenderAddress
    Debug.Print "Message arrived: " + objPictureMessage.PDUs.Item(1).ArrivalDate

End If

 


© 2002, 2003 Active busineSMS.com Software  
All rights reserved  

MercuryXMS™ - MMS, SMS, WAP Push and EMS mobile messaging software Sitemap