October 14, 2009

Sending SMS

Windows Mobile SDK allows developers to send SMS from their application. For that matter, there is a special object model called as Pocket Outlook Object Model (POOM), which allows developers to access Pocket Outlook data (Contacts, SMS, Email, Appointments, Tasks) from device.

SmsMessage sms = new SmsMessage();
sms.To.Add(new Recipient("Mayur Tendulkar", "+919561051234"));
sms.Body = "This is a test message";
sms.Send();

But unfortunately, when SMS is sent, there is no track of it. By default, neither this sent SMS will appear in ‘Sent Items’ folder nor there will be any delivery receipt. This SMS will be sent silently.

Luckily, POOM also have another class, using which developers can send the SMS and they can keep a track of it. This ways, end-users will get delivery receipts and SMS will appear in ‘Sent Items’ folder. To send SMS using this way, use following code.

OutlookSession os = new OutlookSession();
MessagingApplication.DisplayComposeForm(os.SmsAccount.Name,
"+919561051234");

This is too good. With just two (2) lines of code, WM provides, a SMS sending dialog box (just like Common Dialog Box Objects, e. g. FileOpen, FileSave, Font, ColorPicker,..)

Apart from this, it also has spell checking, dictionary facilities.

You can find more information about this MessagingApplication.DisplayComposeForm at http://tinyurl.com/yff83hd

I hope, this will help you to build SMSable Apps.
Happy Coding.
Namaste
Mayur Tendulkar