Thursday, November 19, 2009

How to send a SMS using C# (Compact Framework) in Windows Mobile

Sending SMS though our own application is very necessary when we talking business application. Windows Mobile SDK comes with PocketOutlook that we can use to send SMSs.

First you need to create a smart device application. and layout your form as below.

image

Then add the PoketOutlook assemply to your application as a reference.

image image

here is the code.

Method1

using Microsoft.WindowsMobile.PocketOutlook;
private void btnSend_Click(object sender, EventArgs e)
{
String number = txtNumber.Text;
String boby = txtBody.Text;
SmsMessage message = new SmsMessage(number,boby);
message.Send();
}

Method2 – Send SMS to Multiple recipients

private void btnSend_Click(object sender, EventArgs e)
{
SmsMessage message = new SmsMessage();

Recipient r1 = new Recipient("Name1", txtNumber.Text);
Recipient r2 = new Recipient("Name2", "0772789456");

message.To.Add(r1);
message.To.Add(r2);

message.Body = txtBody.Text;

message.Send();
}
Post a Comment