我想以编程方式发送短信,因为我正在使用下面的代码,但似乎它在8.1中工作
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();
有没有其他办法来实现它?
答案 0 :(得分:2)
public async static Task SendMessage (string phoneNumber)
{
ChatMessage msg = new ChatMessage();
msg.MessageKind = Windows.ApplicationModel.Chat.ChatMessageKind.Standard;
msg.Body = "...";
msg.Recipients.Add(phoneNumber);
ChatMessageStore cms = await ChatMessageManager.RequestStoreAsync();
cms.SendMessageAsync(msg);
}
这应该在Windows Phone 8.1上发送消息。您可能想检查cms是否为空,以防万一...
答案 1 :(得分:1)
在创建新主题之前,您应该进行一些搜索。您的问题已经成为this thread的一部分。通用应用程序也称为Windows运行时,如果您要发送消息或事件调用或发送电子邮件,则在that threat中使用相同的解决方案。 您可以将此用于发送消息:
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);
享受编码!
P / s:从@Sinaesthetic更新,这只是撰写邮件,它不会发送它,所有用户要做的就是点击发送按钮:)