advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
Rate this item | 0 users have rated this item.
Email this articleEmail this article
 
SMS Messaging Using the .NET Compact Framework
SMS messaging may have it's drawbacks, but it's benefits make it a viable solution for many of today's enteprise applications. This article uses a sample hospital application to show you how to integrate SMS messaging using the .NET Compact Framework.  

advertisement
MS messaging is one of the many ways in which your Windows Mobile application[s] connect to the outside world. The key advantage to SMS is that as long as the device has a valid SIM card, it is able to send and receive SMS messages. Unlike using web services (which uses a request and response communication model), SMS messaging is asynchronous in nature—messages are sent and received as and when needed. Also unlike sockets programming, SMS messaging does not require building a client and server in order to send and receive data—all relaying is taken care of by the cellular network. There are downsides, however: Using SMS messaging can be costly and delivery is non-guaranteed. That said, SMS messaging is still a viable solution for many enterprise applications in use today.

This article will show you how to use SMS messaging in a real-world application. The sample application is used in a hospital where nurses are equipped with Windows Mobile devices. When a patient is admitted to the hospital, SMS messages are sent to the nurses in charge to notify them of the various events happening, such as patients' admission, patients' discharging, etc. The sample project uses the .NET Compact Framework to integrate SMS messaging into the application.

Sending SMS Message
Using Visual Studio 2008, create a new Windows Mobile 6 Professional application using C#. Name the project SMSMessaging.

To use SMS messaging in a Windows Mobile application, you need to add a reference to the following DLLs:

  • Microsoft.WindowsMobile.dll
  • Microsoft.WindowsMobile.PocketOutlook.dll
Populate the default Form1 with the controls shown in Figure 1.

Figure 1. Form1: Populating the default Form1 with the various controls.

For simplicity's sake, hardcode the lblEmployeeID control with a fixed employee ID. Also, add a few items into the cbbLocation control: Ward 1, Ward 2, Ward 3, and so on.

Switch to the code-behind of Form1 and import the following namespace:


using Microsoft.WindowsMobile.PocketOutlook;
Within the Form1 class, define the constant representing the phone number of the HQ where you can send acknowledgement messages to:

    public partial class Form1 : Form
    {
        const string HQPhoneNo = "651234567";
In the first part of this project, you'll be enabling a nurse to send his/her location to a central server through SMS. Code the Send Location via SMS button as follows:

        private void btnSendSMS_Click(object sender, EventArgs e)
        {
            try
            {
                SmsMessage sms = new SmsMessage()
                {
                    Body = lblEmployeeID.Text + "|" + cbbLocation.Text
                };
                sms.To.Add(new Recipient(HQPhoneNo));
                sms.Send();
                MessageBox.Show("Message sent!");                            
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);            
            }
        }
The SmsMessage class (located in the Microsoft.WindowsMobile.PocketOutlook namespace) allows you to send a SMS message to one or more recipients. In the code above, if a nurse is current in Ward 5, the application will send a SMS message with the following content (in the format <EmployeeID>|<Ward No.>):

745402|Ward 5

  Next Page: Intercepting SMS Messages
Page 1: IntroductionPage 3: Filtering SMS Messages
Page 2: Intercepting SMS MessagesPage 4: Registering the Application with the Device
Untitled
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Intel PDF: Virtualization Delivers Data Center Efficiency
Intel eBook: Managing the Evolving Data Center
Microsoft Article: BitLocker Brings Encryption to Windows Server 2008
Symantec eBook: The Guide to E-Mail Archiving and Management
Microsoft Article: RODCs Transform Branch Office Security
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
Avaya Article: Advancing the State of the Art in Customer Service
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Avaya Article: Avaya AE Services Provide Rapid Telephony Integration with Facebook
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Seminar: Efficiencies in Hardware/Software Virtualization
HP Webcast: Disaster Recovery Planning
Go Parallel Video: Performance and Threading Tools for Game Developers
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
IBM TCO eKIT: Your IT Budget is Under Attack, Get in Control
IBM Energy Efficiency eKIT: Learn How to Reduce Costs
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Microsoft Article: Silverlight Streaming--Free Video Hosting for All
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
HP Demo: StorageWorks EVA4400
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES