Sample C# Application to Send SMS from Windows Mobile 5

February 5, 2009 · Filed Under SMS · Comment 

Hey Devs,

                 The following piece of code will send SMS from your application.

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Telephony;
using Microsoft.WindowsMobile.PocketOutlook;

namespace SBSMProj
{
    public partial class SendSMS : Form
    {
        public SendSMS()
        {
            InitializeComponent();
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            MessageBox.Show(“Thanks for playing fair”);
            Application.Exit();
        }

        private void mnuMessage_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(mobileNumber.Text))
            {
                MessageBox.Show(“Please Enter Mobile #”,”SB”);
            }
            else if (string.IsNullOrEmpty(smsMessage.Text))
            {
                MessageBox.Show(“Please Enter Message”, “SB”);
            }
            else
            {
                SmsMessage sms = new SmsMessage(mobileNumber.Text, smsMessage.Text);
                sms.Send();
                MessageBox.Show(“Message Sent Successfully to ” + mobileNumber.Text);

                mobileNumber.Text = “”;
                smsMessage.Text = “”;
            }
        }

    }
}

Sample Screen Shots

mob1

Click Send Message

mob2