How to use the SMS compose task for Windows Phone 8

How to use the SMS compose task for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Use the SMS compose task to enable users to send a message from your application. The SMS compose task launches the Messaging application with a new SMS message displayed. You can optionally specify recipients and a message body that are prepopulated in the new message. The message is not sent until the user presses the send button.

By using Launchers, you help provide a consistent user experience throughout the Windows Phone platform. For more information, see Launchers and Choosers for Windows Phone 8.

NoteNote:

On Windows Phone Emulator, the SMS message always appears to be sent successfully, but the message is not actually sent. The emulator uses Fake GSM and always has a false Subscriber Identity Module (SIM) card.

To use the SMS compose task

  1. Add the following statement to your code.

    Imports Microsoft.Phone.Tasks
    
  2. Add the following code to your application wherever you need it, such as in a button click event. To test this procedure, you can put the code in the page constructor. This is the code to launch the task.

    Dim smsComposeTask As SmsComposeTask = new SmsComposeTask()
    
    smsComposeTask.To = "2065550123"
    smsComposeTask.Body = "Try this new application. It's great!"
    
    smsComposeTask.Show()
    
    NoteNote:

    If the phone does not have a SIM card, the phone receives a toast notification when the message fails to be sent.

Show:
© 2017 Microsoft