There is an extremely easy way to intercept SMS in WM2005. Microsoft.WindowsMobile.PocketOutlook provides many useful objects to manipulate Pocket Outlook in WM devices. I am particularly interested with the MessageInterceptor object.
In this tutorial, I will share with you a simple Proof-of-Concept WM device application using MessageInterceptor object. This application intercepts a SMS and renders the message body into a QRcode on the form.
A free .NET QRcode encoder for both desktop and compact framework is found at http://www.codeproject.com/KB/cs/qrcode.aspx
First things first
I assume you have/know the following:
• A WM2005 or above phone device to test with (I can rent you one…)
• Visual Studio 2005 with the relevant Windows Mobile SDK
• You know how to create a simple WM “device-application” project
Adding References & Namespaces
Add Microsoft.WindowsMobile & Microsoft.WindowsMobile.PocketOutlook
In your Form1.cs (or whatever your form class file is), add these:
using Microsoft.WindowsMobile.PocketOutlook;
using Microsoft.WindowsMobile.PocketOutlook.MessageInterception;
using System.Drawing.Imaging;
using ThoughtWorks.QRCode.Codec;
using ThoughtWorks.QRCode.Codec.Data;
using ThoughtWorks.QRCode.Codec.Util;
Adding UI Elements
In this example, I used a PictureBox, Listbox & 2 Buttons.
![]() |
Adding Interceptor object & handler
Declare MessageInterceptor in the class for the Form since we want to intercept message throughout the lifespan of the form. In other words, DO NOT CREATE a local object inside a method.
public partial class Form1 : Form
{
MessageInterceptor nSms;public Form1()
{
InitializeComponent();
}
…
Instantiate the interceptor during Form load:
private void Form1_Load(object sender, EventArgs e)
{
nSms = new MessageInterceptor();
nSms.MessageReceived +=new MessageInterceptorEventHandler(nSms_MessageReceived);
}
In this case, nSms_MessageReceived is the delegated handler and it looks something like this:
void nSms_MessageReceived(object sender, MessageInterceptorEventArgs e)
{
if (e.Message is SmsMessage)
{
SmsMessage sms = (SmsMessage)e.Message;
listBox1.Items.Add(sms.Body);
createQR(sms.Body);
this.Show();
}
else
listBox1.Items.Add(“unknown message”);
listBox1.Items.Add(e.Message.From.Address.ToString());
listBox1.Items.Add(e.Message.From.Name.ToString());
}
Sending SMS
Sending SMS in a WM device app is a no brainer…
private void button1_Click(object sender, EventArgs e)
{
SmsMessage a = new SmsMessage(“91234567″, “The quick brown fox jump over the dead dog”);
a.Send();
}
Let’s waste some SMS
At this point in time, give yourself a pat and waste some SMS by sending some to the device running this application.
![]() |
Anyone who’d experienced development with COM-based Pocket Outlook Object Model or POOM will appreciate this tutorial because it is now almost idiot-proof and painless compared to using POOM.
I deliberately left out the QRcode encoding and leave it to your imagination to what you can do with intercepted SMS. The reader may wish to explore the free QRcode encoder for some hands-on exercise.





Entries (RSS)