SMS application

Hi,

I’m working on a Pocket PC application in VB.Net on Compact Framework.

It is required that we develop a SMS module.

What is the functionality (code )that should be provided to the Click event of the SEND button.

Thanks,



Answer this question

SMS application

  • fettoter

    Hi,

    We tried using the VB code in our project and it worked just fine :) The sms was sent from the PocketPC application to another mobile device.

    The SMS was received in the destination mobile too but,

    The message just flashed directly on the screen It didnt get stored in the "Inbox".

    It is required that the SMS gets saved automatically in the "Inbox" of the mobile phone.

    On reading through the code we found that in the method SmsSendMessage the parameter-- ProvData is used for Provider Data.

    And the enum PROVIDER_SPECIFIC_MESSAGE_CLASS,

    Public Enum PROVIDER_SPECIFIC_MESSAGE_CLASS

    PS_MESSAGE_CLASS0 = 0

    PS_MESSAGE_CLASS1

    PS_MESSAGE_CLASS2

    PS_MESSAGE_CLASS3

    End Enum 'PROVIDER_SPECIFIC_MESSAGE_CLASS

    decides whether the message should get saved in the inbox or just flash across the screen(as described in the writeup on the msdn link):

    retVal = SmsSendMessage(smsHandle, 0, smsAddress, 0, smsMessage, smsMessageTag.Length, _

    ProvData, 12, SMS_DATA_ENCODING.SMSDE_OPTIMAL, SMS_OPTION_DELIVERY_NONE, 0)

    Apparently , this parameter "ProvData" is passed as an "empty" byte array.

    We tried including the value PS_MESSAGE_CLASS1 (to save message in inbox) in it as shown below:

    Dim ProvData() As Byte = BitConverter.GetBytes(PROVIDER_SPECIFIC_MESSAGE_CLASS.PS_MESSAGE_CLASS1)

    retVal = SmsSendMessage(smsHandle, 0, smsAddress, 0, smsMessage, smsMessageTag.Length, _
    ProvData, ProvData.Length, SMS_DATA_ENCODING.SMSDE_OPTIMAL, SMS_OPTION_DELIVERY_NONE, 0)

    But this didnt work. Where did we go wrong Any idea on how this can be accomplished the correct way

    Many thanks,


  • sreevidya

    Are you asking for someone to write your code

  • LankyNibbs

    the correct code is:

    Dim smsAddress As IntPtr = Marshal.AllocHLocal(smsAddressTag.Length)

    The Marshal class is from NetCF.Runtime.InteropServicesname space, which is included in demo VB project

    Public Shared Function AllocHLocal(ByVal cb As Int32) As IntPtr

    Try

    Return WinApi.LocalAlloc(WinApi.LPTR, cb)

    Catch ex As Exception

    End Try

    End Function

    System.Runtime.InteropServices.Marshal.Copy() is a from different namespace



  • scripteaze

  • arcliner

    Hi LProgrammer,
    Did you ever find a solution in managing to save an intercepted SMS message to the inbox I'm trying to do the same thing. Thanks very much.

    Best regards,
    Tian
    pentian@<REMOVE>gmail.com

  • Kardath

    Yes, you are absolutely right!

    But if he uses WM 2003 it will work too!

    Not all people works with WM5 yet

    :-)



  • Ehsan Enaloo

    Hi,

    Thanks for the quick response :)

    Will download the code and try it out !

    Thanks again!


  • pjtaylor

    Tihomir Ignatov wrote:

    Hi,

    Try this:

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnnetcomp/html/netcfsendsms.asp

    This has been written for Compact Framework v1 and PPC 2002. If the target device is WIndows Mobile 5 device there is also a class called Microsoft.WindowsMobile.PocketOutlook.SmsMessage. Another class - Microsoft.WindowsMobile.PocketOutlook.MessageInterception.MessageInterceptor - allows intercepting SMS messages before they reach inbox



  • Mark Goldstein

    Hi ,

    Thanks for the link.It definitely got me started :)

    What follows is the code written to allocate memory to the IntPtr variable that is to hold the Destination Phone Number.

    Dim PhNum As Byte() = System.Text.ASCIIEncoding.Default.GetBytes("363457345")
    Dim SMSAddress As IntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(PhNum.Length)
    System.Runtime.InteropServices.Marshal.Copy(PhNum, 0, SMSAddress, PhNum.Length)

    This code gives a compilation error :(

    error BC30456: 'AllocHGlobal' is not a member of 'System.Runtime.InteropServices.Marshal'.

    I have included the statement
    Imports System.Runtime.InteropServices
    at the start of the application.

    Where am I going wrong Why is the compiler failing to identify the method 'AllocHGlobal' as part of the 'Marshal' class

    There is no such Compilation error for the 'Copy' method which also belongs to the same class 'Marshal'

    Thanks,


  • SMS application