在WP7/8中,发送短信是利用了EmailComposeTask和SmsComposeTask来实现的。

在WP8.1 Store App中,原来的方式已经失效,采用了新的方法:ChatMessageManager和EmailManager管理和发送信息。

简单使用:

private async void SendSmsTask(string body,string phoneNum)
{
var chatMessage = new Windows.ApplicationModel.Chat.ChatMessage();
chatMessage.Body = body;
chatMessage.Recipients.Add(phoneNum);
await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
}
private async void SendEmailTask(string body, string emailAddress)
{
var emailMessage = new EmailMessage();
emailMessage.Body = body;
emailMessage.To.Add(new EmailRecipient(emailAddress));
await EmailManager.ShowComposeNewEmailAsync(emailMessage);
}

msdn的介绍:

private async void ComposeSms(Windows.ApplicationModel.Contacts.Contact recipient,string messageBody,StorageFile attachmentFile,string mimeType)
{
var chatMessage = new Windows.ApplicationModel.Chat.ChatMessage();
chatMessage.Body = messageBody; if (attachmentFile != null)
{
var stream = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(attachmentFile); var attachment = new Windows.ApplicationModel.Chat.ChatMessageAttachment(
mimeType,
stream); chatMessage.Attachments.Add(attachment);
} var phone = recipient.Phones.FirstOrDefault<Windows.ApplicationModel.Contacts.ContactPhone>();
if (phone != null)
{
chatMessage.Recipients.Add(phone.Number);
}
await Windows.ApplicationModel.Chat.ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
} private async void ComposeEmail(Windows.ApplicationModel.Contacts.Contact recipient,string messageBody,StorageFile attachmentFile)
{
var emailMessage = new Windows.ApplicationModel.Email.EmailMessage();
emailMessage.Body = messageBody; if (attachmentFile != null)
{
var stream = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(attachmentFile); var attachment = new Windows.ApplicationModel.Email.EmailAttachment(
attachmentFile.Name,
stream); emailMessage.Attachments.Add(attachment);
} var email = recipient.Emails.FirstOrDefault<Windows.ApplicationModel.Contacts.ContactEmail>();
if (email != null)
{
var emailRecipient = new Windows.ApplicationModel.Email.EmailRecipient(email.Address);
emailMessage.To.Add(emailRecipient);
} await Windows.ApplicationModel.Email.EmailManager.ShowComposeNewEmailAsync(emailMessage); }

原文:

http://www.liubaicai.net/?p=300

最新文章

  1. Processing 电子罗盘校准(以 MPU9250为例)
  2. 提高生产性工具(四) - XML数据库的尝试
  3. 三进制状压 HDOJ 3001 Travelling
  4. 邮件格式(HTML/TXT),TXT为文本邮件
  5. C# 对List&lt;T&gt;取交集、连集及差集
  6. Django实际站点项目开发经验谈
  7. 改变服务器sshd 的22的端口
  8. C#打开一个文本文件并读写
  9. 把NodeJS注册成Windows服务
  10. 使用GitHub进行协同项目开发和开源项目贡献
  11. Windows Python 2.7 安装 Numpy
  12. deep learning 学习资料
  13. (转)PHP中extract()函数的妙用
  14. Linux设备驱动中断机制
  15. Spring Boot Logback应用日志
  16. C++STL之set容器及stream类
  17. iOS上传AppStore被拒原因及处理方案
  18. MySQL学习分享--&gt;查询--&gt;查询的分类
  19. CoreAnimation 视觉效果
  20. Spring-quartz 可传参(包括service注入)任务调度 多个任务调度

热门文章

  1. Django中的Model、Form和ModelForm
  2. django-连接mysql失败
  3. Windows10 IME占用过高临时解决办法
  4. 0 1 1 2 3 5 8 13 21 34 求第N个, 用js实现
  5. MyBatis 注解式开发
  6. css常用属性总结:文本属性中的text-indent
  7. python:dist-packages &amp;&amp; site-packages
  8. 11. Container With Most Water 装水最多的容器
  9. __slots__(面向对象进阶)
  10. C语言压缩/解压缩