Microsoft je izradio klasu koja pruza podrsku za slanje sms poruka sa pda uredjaja koji na sebi imaju Windows Mobile. Radi se o klasi: SmsMessage Class (http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.pocketoutlook.smsmessage.aspx).
Evo jednostavnog koda koji vrsi slanje sms-a sa pda uredjaja:
private void mnuSendSMS_Click(object sender, EventArgs e)
{
// send sms
if (txtMobNumber.Text.CompareTo("") == 0)
{
MessageBox.Show("Niste popunili broj telefona!", "Greska", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
return;
}
SmsMessage smsMessage = new SmsMessage();
smsMessage.Body = txtBody.Text;
smsMessage.To.Add(new Recipient("Tester", txtMobNumber.Text));
smsMessage.RequestDeliveryReport = true;
try
{
Cursor.Current = Cursors.WaitCursor;
smsMessage.Send();
}
catch (ServiceCenterException scEx)
{
// Thrown when there is a service center error sending the SMS message.
MessageBox.Show("ServiceCenterException: " + scEx.Message);
}
catch (InvalidSmsRecipientException invRecEx)
{
// Thrown when the SMS recipient is invalid.
MessageBox.Show("InvalidSmsRecipientException: " + invRecEx.Message);
}
catch (Win32Exception ex)
{
// Thrown when there is no support for SMS.
MessageBox.Show("Win32Exception: " + ex.Message);
}
finally
{
Cursor.Current = Cursors.Default;
}
}
Naravno, pre nego pokusate da posaljete sms poruku, ne zaboravite da ubacite sim karticu ukoliko to uredjaj podrzava. :>
Uzivajte u programiranju :)