Windows Phone 8.1 and Windows Runtime Apps How to #11 – How to Send SMS in Windows Phone 8.1 XAML App ?

In the Windows Phone 8.0 and earlier version , the developers could utilize the SMSComposeTask to send SMS from the Windows Phone App. If you are targeting the Windows Phone 8.1 Silverlight model , this will still work fine . How about sending SMS from Windows Runtime App ?

How to Send SMS in Windows Phone 8.1 XAML(Windows Runtime) App ?

If you are targeting the Windows Phone 8.1 XAML App(Windows Runtime App) , you can use the ChatMessage class defined in the Windows.ApplicationModel.Chat namespace.

Below is a sample code snippet demonstrating how to send SMS from a Windows Phone 8.1 App.

async private void Button_Click(object sender, RoutedEventArgs e)
{
    ChatMessage chat = new ChatMessage();
    chat.Body = "Subject : This is a Test SMS from developerpublish.com";
    chat.Recipients.Add("000000");
    await Windows.ApplicationModel.Chat.ChatMessageManager.ShowComposeSmsMessageAsync(chat);
}

image

Leave a Reply