How to send a SMS message from within an Windows Phone 8.1 app

a 夏天 提交于 2020-01-05 12:24:10

问题


I would like to create a Windows Phone 8.1 app that sends the location of the device to a contact in the contact list of the phone via a SMS message. How do I send a SMS message?


回答1:


In Windows Phone 8.1, You can send sms using ChatMessageManager:

Windows.ApplicationModel.Chat.ChatMessage msg 
         = new Windows.ApplicationModel.Chat.ChatMessage();
msg.Body = "This is body of demo message.";
msg.Recipients.Add("10086");
msg.Recipients.Add("10010");
await Windows.ApplicationModel.Chat.ChatMessageManager
         .ShowComposeSmsMessageAsync(msg);

There are 2 important params in it: Body and Recipients.

Body is the content you will send.

Recipients is the contact list who will receive the sms.




回答2:


You can use the SMS Compose Task to send an SMS message: http://msdn.microsoft.com/en-us/library/windows/apps/hh394005(v=vs.105).aspx

SmsComposeTask smsComposeTask = new SmsComposeTask();

smsComposeTask.To = "2065550123";
smsComposeTask.Body = "Try this new application. It's great!";

smsComposeTask.Show();



回答3:


Try this

 SmsComposeTask SMSCompose = new SmsComposeTask();
 SMSCompose.To = "<Number to which the SMS needs to be sent";
 SMSCompose.Body = "Message that needs to be sent";
 SMSCompose.Show();


来源:https://stackoverflow.com/questions/24894069/how-to-send-a-sms-message-from-within-an-windows-phone-8-1-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!