using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Microsoft.WindowsMobile;
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;

namespace InterceptSMS_CS
{
    public partial class Form1 : Form
    {
        private MessageInterceptor smsInterceptor;
                

        public Form1()
        {
            InitializeComponent();

            #if DEBUG
                MinimizeBox = false;
            #else       
                MinimizeBox = true;
            #endif         
        }

        private void smsInterceptor_MessageReceived(object sender,
              MessageInterceptorEventArgs e)
        {
            // Обработка входящего сообщения
            MessageBox.Show("К вам пришло срочное сообщение");
            SmsMessage sms = (SmsMessage)e.Message;
            lblInfo.Text = sms.Body;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            smsInterceptor = new MessageInterceptor(InterceptionAction.NotifyAndDelete, true);
            smsInterceptor.MessageCondition = new MessageCondition(
              MessageProperty.Body,
              MessagePropertyComparisonType.StartsWith,
              "Oops",  true);
            smsInterceptor.MessageReceived += new MessageInterceptorEventHandler
            (smsInterceptor_MessageReceived);
        }
    }
}