|
message master™ SMS SDK Sample
The message master™ SMS SDK facilitates and accelerates the
integration of SMS and EMS messaging into your custom application. It is
used by hundreds of software developers around the globe including companies
like Symantec, Microsoft, HP.
We have included some source code examples to show you how the ActiveXMS Mobile
Messaging SDK is used to encode and decode EMS content received through the
message master™ SMS SDK.
Here is an example for creating (encoding) the PDU strings for
a message containing a Picture, Animation and some Formatted Text.
Please note that you may need to adjust the encoding settings depending
on the type of gateway you are connecting to.
Dim objEncoder As New EMSMessageManager
Dim objMessage As EMSMessage
Dim objPicture As EMSPictureComponent
Dim objText As EMSTextComponent
Dim objAnimation As EMSAnimationComponent
Dim objPDU As EMSPDU
Dim lResult As Long
'Create a new message
Set objMessage = objEncoder.CreateEMSMessage("")
'Add the picture
Set objPicture = objMessage.AddComponent(emsComponent_Picture)
objPicture.PictureType = emsPictureType_UserDefined
objPicture.BitmapFilename = "c:\image.bmp"
objPicture.CopyProtected = True
'Add the animation
Set objAnimation = objMessage.AddCompnent(emsComponent_Animation)
objAnimation.Animation = emsAnim_Laughing
'Add the text
Set objText = objMessage.AddComponent(emsComponent_Text)
objText.MessageText = "Happy Birthday"
objText.Alignment = emsTextAlign_Center
objText.FontSize = emsTextFont_Large
objText.Bold = True
'Refresh the PDUs
objMessage.GeneratePDU
'Iterate through PDUs collection to send
For Each objPDU In objMessage.PDUs
lResult = MessageMaster1.MessageSend(0, _
Service.Text,
Number.Text, "", Now(), "128", _
objPDU.EMSUserData)
Next
Here is an example for decoding an incoming EMS Message. Note that this code
is implemented in the MessageIncoming event:
Private Sub MessageMaster1_MessageIncoming(ByVal lMessageType As Long, ByVal
bstrOriginator As String, ByVal bstrDestinator As String, ByVal dateTimeStamp As
Date, ByVal bstrMessageString As String, ByVal bstrInfo As String)
Dim objDecoder As New
EMSMessageManager
Dim objEMSMessage As EMSMessage
Dim objPicture As EMSPictureComponent
Dim objText As EMSTextComponent
Dim objComponent As EMSComponent
Dim objPDU As EMSPDU
'Is this an EMS message?
If objDecoder.IdentifyPDU(bstrMessageString) <>
emsMessageType_EMSMessage Then
Exit Sub
End If
'Decode the incoming message
Set objEMSMessage = objDecoder.DecodePDU(bstrMessageString)
'Do we have the complete message?
If objEMSMessage.DecodeState = emsDecodeState_MultipartIncomplete Then
Exit Sub 'Come back
later with the next PDU
End If
'We now have the complete message
For Each objComponent In objEMSMessage.Components
Select Case
objComponent.ComponentType
Case emsComponent_Picture:
Set objPicture =
objComponent
'Report on some of the incoming message properties
Debug.Print "Image: " + objPicture.BitmapFileName
Debug.Print "Sent from: " + objPicture.SenderAddress
Case emsComponent_Text:
Set
objText = objComponent
'Report on some of the incoming message properties
Debug.Print "Text: " +
objText.MessageText
Debug.Print "Bold: " +
CStr(objText.Bold)
End Select
Next
End Sub
Click here to see the Derdack SMSC
Connectivity SDK Code Sample
|