Reading SMS Message Inbox

Hi,

here's yet another "How do I read the SMS inbox" question, but I'm going into detail.
I have invested several days into research how to do it in Compact Framework 2.0, but now I'm stuck.

My status is as follows:

  • Microsoft.WindowsMobile.PocketOutlook (of Pocket PC 5.0 SDK) only supports receiving SMS messages and reading contacts, tasks, etc. but not the message inboxes (why ).
  • I have tried to use Interop to cemapi.dll functions, but eg. I cannot call a function of a unmanaged class via Interop (eg. pTable->QueryRows) (I only have an IntPtr of pTable)
  • I have tried to create an ATL COM Library in C++ (for Windows Mobile 5.0 PPC SDK) to get all message IDs of the messages in the inbox and then to open in .NET CF via Interop), but I cannot compile.

So my questions are:

  • Is it possible to get all inbox items of an SMS store with managed classes only
  • If not, is it possible to easily access cemapi.dll via COM Interop in .NET CF 2.0 (is there a .tlb or .idl availably anywhere )
  • If not, are there any C++ examples available where the itemIDs of all messages in a folder are read

Thanks in advance,
Klaus



Answer this question

Reading SMS Message Inbox

  • mogens

    That error generally means you forgot to add required libraries to the linker's options. Just look up which library contains particular function on MSDN (usually listed on the bottom of the page together with include file) and add it.



  • ADurkin

    Hi!

    I am running into the exact same problem; including the part where it does not compile. Existing solutions, e.g. demos from Microsoft, combile successfully, but I cannot create my own project. Anyway, I would like to achieve the same tak: exporting SMS messages. Or at least reading them.

    Did you manage to do anything

    Regards,

    An e


  • Bing M.

    Can you please elaborate on specific issues you're facing Maybe you're not including the correct references or not linking to the correct libraries.

    Manav



  • Sugan

    Ok, I'll go bang my head into a wall now...

    Thanks, that was the issue :-). I never suspected it though. One can see I'm a .NET programmer I gues...

    Bye, Anze


  • Colin Bowern

    Oh no, why C++, can you give sample or code in C# or using .NET CF library

    Thanks,

  • dotaboy

    This code shows you how to retrieve the body text of the SMS when it arrives

    public partial class Form1 : Form
    {

    MessageInterceptor msgIcptr = new MessageInterceptor(InterceptionAction.Notify);

    public Form1()

    {
    msgIcptr.MessageReceived += new MessageInterceptorEventHandler(msgIcptr_MessageReceived);
    InitializeComponent();
    }

    void msgIcptr_MessageReceived(object sender, MessageInterceptorEventArgs e)
    {
    try{
    SmsMessage elMSG = (SmsMessage)e.Message;
    MessageBox.Show(elMSG.Body);
    }

    catch { }
    }
    }



  • Bill Reiss

    Ok, I create a new Smart phone project. I add the platform for WM 5.0, and this is the code:

    #include "stdafx.h"
    #include <WINDOWS.H>
    #include <COMMCTRL.H>
    #include "cemapi.h"
    #include "mapix.h"
    #include "mapi.h"
    
    
    int _tmain(int argc, _TCHAR* argv[])
    {
     HRESULT hr;
     ICEMAPISession * pSession = NULL;
    
     hr = MAPIInitialize(NULL);
     hr = MAPILogonEx(0, NULL, NULL, 0, (LPMAPISESSION *)&pSession);
    
     return 0;
    }

    this is where It stops working as it says:

    Error 1 error LNK2019: unresolved external symbol MAPILogonEx referenced in function wmain Test.obj
    Error 2 error LNK2019: unresolved external symbol MAPIInitialize referenced in function wmain Test.obj
    Error 3 fatal error LNK1120: 2 unresolved externals Windows Mobile 5.0 Smartphone SDK

    when I run a sample from Microsoft for example, It works, and I can use any function I want.

    Any Idea on what could be the cause

    Thanks,
    An e


  • Raymundo Chapa94595

  • Reading SMS Message Inbox