0

Can anyone help me how to send sms in vb 6.0 using nokia mobile connected through pcsuite.

Below is the code im using . iam getting error in the Call pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY, pIGSMSubmit). it is saying that object variable or with block variable not set

Private lngEventCounter As Long
Private pFolderList() As NokiaCLMessaging.ShortMsgFolderItem
Private pSMSAdapter As NokiaCLMessaging.ShortMsgAdapter
Private pIGSMSubmit As NokiaCLMessaging.IGSMSubmit
Private pSMSMessageItem As NokiaCLMessaging.ShortMessageItem
Private pIGSMDeliver As NokiaCLMessaging.IGSMDeliver
Private pIMemory As NokiaCLMessaging.IMemory
Private pFreeIdxs As Variant
Private pFreeSimIdxs As Variant
Private pCurrentFolderIndex As Byte
Private pMsgPart1 As String
Private pMsgPart2 As String
Private Const CODING_SCHEME_UNICODE = 8
Private Const CODING_SCHEME_TEXT = 0
Private Const SMS_TEXT_MAX_SIZE = 160
Private Const SMS_UNICODE_MAX_SIZE = 70
Private Const SMS_CONCATENATED_TEXT_MAX_SIZE = 153
Private Const SMS_CONCATENATED_UNICODE_MAX_SIZE = 67
Private parameterEntry As NokiaCLMessaging.IGSMParameters
Private Sub SendConcatenatedMessage()

On Error GoTo ErrorTrap

    Dim smsEntry As NokiaCLMessaging.ShortMessageItem
    Set smsEntry = New NokiaCLMessaging.ShortMessageItem

    Dim headerArray(0 To 5) As Byte

    smsEntry.Type = SHORTMESSAGE_TYPE_GSM_SUBMIT
    Set pIGSMSubmit = smsEntry.TypeProperties

    pIGSMSubmit.message = pMsgPart1
    pIGSMSubmit.DestinationAddress = txtDestinationNumber.Text
    pIGSMSubmit.ServiceCenterAddress = "+919894051914"
    pIGSMSubmit.ProtocolID = 0
    pIGSMSubmit.DataCodingScheme = 0
    pIGSMSubmit.ValidityPeriodRelative = 255

    headerArray(0) = 5 'header lenght
    headerArray(1) = 0 'concatenated sms
    headerArray(2) = 3 'length of information element A
    headerArray(3) = 50 'reference number
    headerArray(4) = 2 '2 messages
    headerArray(5) = 1 'sequence number of sms

    pIGSMSubmit.UserDataHeader = headerArray

    Call pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY, pIGSMSubmit)

    pIGSMSubmit.message = pMsgPart2
    pIGSMSubmit.DestinationAddress = txtDestinationNumber.Text
    pIGSMSubmit.ServiceCenterAddress = "+919894051914"
    pIGSMSubmit.ProtocolID = 0
    pIGSMSubmit.DataCodingScheme = 0
    pIGSMSubmit.ValidityPeriodRelative = 255

    headerArray(0) = 5 'header lenght
    headerArray(1) = 0 'concatenated sms
    headerArray(2) = 3 'length of information element A
    headerArray(3) = 51 'reference number
    headerArray(4) = 2 '2 messages
    headerArray(5) = 2 'sequence number of sms

    pIGSMSubmit.UserDataHeader = headerArray

    Call pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY, pIGSMSubmit)
    MsgBox ("Concatenated MEssage sent")

Exit Sub

ErrorTrap:
    MsgBox Err.Description, vbInformation, "Error Concatenate Message"
End Sub

Private Sub Form_Load()

End Sub
Yuvaraj
  • 166
  • 1
  • 2
  • 11
  • Sorry Steve by mistake i tagged vb.net . i edited my post and put the vb coding what i have used. will you please help me to sort it out ? – Yuvaraj Mar 20 '13 at 08:47

1 Answers1

1

This forum post talks about this exact topic - did you try Googling before you asked the question?

http://www.developer.nokia.com/Community/Discussion/showthread.php?159438-Send-SMS-in-Visual-Basic-using-Mobile-Phone-as-Modem

Now you have added some code it appears that you have not initialised the object - hence the error. Try something liek this:

Set pSMSAdapter = New NokiaCLMessaging.ShortMsgAdapter
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
  • yes but im getting an error at Call pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY, pIGSMSubmit). object variable or with block not set – Yuvaraj Mar 20 '13 at 08:40
  • Thanks very much for your time Matt, the above said problem solved but im getting a new error phone not connected – Yuvaraj Mar 21 '13 at 07:41
  • Thanks for your time Matt .The same line pSMSAdapter.SendSMS(SHORTMESSAGE_ROUTE_TYPE_ANY, pIGSMSubmit) is giving error as mobile not connected . But my mobile is connected through pcsuite and I can send SMS from pcsuite . – Yuvaraj Mar 21 '13 at 18:30