问题描述
我正在写一个应用程序,它会打个电话,在WP 8.1发送短信或电子邮件,就像人的应用程序。
到目前为止,我已经找到了一个链接形式MSDN上面写着:适用于:Windows Phone 8的和Windows Phone的Silverlight 8.1。
所以这里的代码:
I'm writing an app which will make a phone call, send sms or email just like the People app in wp 8.1 .So far I've found a link form msdn which said "Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1".So here the code:from this link
using Microsoft.Phone.Tasks;
private void TextBlock_Tapped_Call(object sender, TappedRoutedEventArgs e)
{
PhoneCallTask phoneCallTask = new PhoneCallTask();
phoneCallTask.PhoneNumber = "2065550123";
phoneCallTask.DisplayName = "Gage";
phoneCallTask.Show();
}
不过,我得到了一个错误:
But I got an error:
类型或命名空间名称'电话'不存在命名空间'微软'(是否缺少程序集引用)
The type or namespace name 'Phone' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
编辑存在:对不起,一个重复的问题,同样在这里:
答案,他也更新代码发送短信和电子邮件。
Sorry for a duplicate question, same here: Make a phone call in Windows Phone 8.1 Answer by @Chris Shao, he also updated code to send SMS and Email.
推荐答案
如果你想使用 Microsoft.Phone.Tasks
,你必须创建的Windows Phone的Silverlight 8.1 项目。如果你的项目的的Windows Phone 8.1
If you want to use Microsoft.Phone.Tasks
, you must create Windows Phone Silverlight 8.1 project. And if your project is Windows Phone 8.1,
您可以使用此代码来电话:
you can use this code to phone call:
Windows.ApplicationModel.Calls.PhoneCallManager.ShowPhoneCallUI("phone number", "display name");
和使用它来发送短信:
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);
和使用它来发送邮件:
Windows.ApplicationModel.Email.EmailMessage mail = new Windows.ApplicationModel.Email.EmailMessage();
mail.Subject = "This is Subject";
mail.Body = "This is body of demo mail";
mail.To.Add(new Windows.ApplicationModel.Email.EmailRecipient("[email protected]", "shaomeng"));
await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(mail);
这篇关于WP 8.1运行时代码,以使电话,发送短信和放大器;发送电子邮件(不Silverlight的8.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!