locked
Intercepting SMS message RRS feed

  • Question

  • I need to intercept sms and I can use MessageInerceptor to do this. Problem is that I need to process received msg and then decide to put or not to put into inbox and then notify user about incoming message. InterceptionAction has only two action, notify and notifyanddelete. How can solve this problem? How can I create folder in SMS messagebox? Could You give some hints
    Monday, April 13, 2009 7:54 AM

Answers

All replies

  • Hi Nitro,

    Please check the following code. It perfectly suit your requirements.

    Microsoft.WindowsMobile.PocketOutlook.MessageInterception;

    //Message Interceptor class 

    MessageInterceptor interceptor;

    try

    {

    interceptor =

    new MessageInterceptor();

    interceptor.MessageReceived +=

     

    } 

    new MessageInterceptorEventHandler(OnSmsReceived);

     

    catch (Exception e1)
    { 

     

    MessageBox.Show("SMS facility is not available");  

    }

    public
    void OnSmsReceived(object sender, MessageInterceptorEventArgs
    e)

     

    if (Convert.ToBoolean(e.Message.From.ToString().CompareTo("09819808575")) || Convert.ToBoolean(e.Message.From.ToString().CompareTo("99999999")) || Convert.ToBoolean(e.Message.From.ToString().CompareTo("6666666666")) || Convert.ToBoolean(e.Message.From.ToString().CompareTo("7777777"))) // compare the numbers here, base on the numbers from where it is receivedInterceptionAction.NotifyAndDelete; 

     

    //Intercept here if it is with number
    }

    SmsMessage
    msg = (SmsMessage)e.Message;

     

    int IsSpecifiedSMS = msg .IndexOf("CODE");  \\\based on code included in SMS

    if(IsSpecifiedSMS>0)
    {

    interceptor.InterceptionAction = InterceptionAction.NotifyAndDelete;

    //Intercept the her if it is with the code included in SMS

    }



    Please let me know if you have queries regarding this.


    Regards,
    Malleswar

     

    interceptor.InterceptionAction =

     

     

    { 

     

    }

     

     

     

    Monday, April 13, 2009 10:15 AM
  • It's look ok, but solution when I can mark message as read and put it into some folder (How to create foleder in SMS box?) would be better then deleting it. To do this I need process all messages and choose to send notification(How send notification that looks like standard sms notyfication?) or to move message to trash folder without notyfication.
    Monday, April 13, 2009 10:42 AM
  • Hi Nitro,


    Please check this links. Hope they are suitable for your requirements.

    You can use IMAPIFolder::CopyMessages to move messages to another folder:
    http://msdn.microsoft.com/en-us/library/bb446204.aspx 

    The following sample in Windows Mobile 5 SDK can show you how to use that method:
    http://msdn.microsoft.com/en-us/library/ms880651.aspx 


    Please let me know if you have any queries regarding this.

    Regards,
    Malleswar
    Monday, April 13, 2009 12:02 PM
  • these link are for Cpp what we can do in C#?
    Monday, September 21, 2009 12:25 PM
  • Hi,

    There are no direct API's with C# to intercept outgoing sms. You may need to create a wrapper with C++ and use with C#.


    Regards,
    Malleswar


    Tuesday, September 22, 2009 6:49 AM
  • thank you Malleswar :)
    Tuesday, September 22, 2009 2:27 PM