在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

WP8.1StoreApp(WP8.1RT)---发送邮件和短信的更多相关文章

  1. WP8.1StoreApp(WP8.1RT)---本地Toast

    WP7/8中的Toast是不能在前台弹出的. WP8.1StoreApp可以利用Win8中的方式: private void Toast(string title,string content) { ...

  2. WP8.1StoreApp(WP8.1RT)---第三方启动

    8.1的协议和wp8是相互通用的 被启动: 相比较wp8而言,基本变化不大,但添加方式更直观了 1:打开Package.appxmanifest 2:切换到"声明"选项卡 3:左侧 ...

  3. WP8.1StoreApp(WP8.1RT)---MessageBox与MessageDialog

    在WP7和WP8中,MessageBox是跟WinForm中一样常用的对话框,但是有一个显著的缺点,就是WP7/8中默认的MessageBox是阻塞线程的.也许是由于这个原因,WP8.1/Win8中采 ...

  4. WP8.1StoreApp(WP8.1RT)---添加推送功能和获取系统信息

    添加推送通知 1:Package.appxmanifest中的声明添加后台任务的推送通知权限 2:var channel = await PushNotificationChannelManager. ...

  5. WP8.1StoreApp(WP8.1RT)---SystemTray的变化

    原Microsoft.Phone.Shell中的SystemTray,已经改到Windows.UI.ViewManagement中StatusBar了. 只能在代码中设置相关属性. 如: 1 2 3 ...

  6. ios开发——实用技术篇Swift篇&地址薄、短信、邮件

    //返回按钮事件 @IBAction func backButtonClick() { self.navigationController?.popViewControllerAnimated(tru ...

  7. 一百四十七:CMS系统之celery实现邮件和短信异步发送

    celery工作原理 celery官方文档:https://docs.celeryproject.org/en/latest/ 安装:pip install celery windows下还需安装ev ...

  8. a标签的妙用-拨打电话、发送短信、发送邮件

    前端时间在做手机WAP网站时,遇到需要点击页面上显示的电话号能直接拨号的需求,查找资料发现可以使用html的a标签完美实现该需求!记录下来以备后用...... 目前主流手机浏览器对H5的支持已经很不错 ...

  9. html拨打电话、发送短信、发送邮件的链接写法

    拨打电话 <a href="tel:88888888">呼叫</a> 发送短信 <a href="sms:88888888"> ...

随机推荐

  1. OpenCL 图像卷积 1

    ▶ 书上的代码改进而成,从文件读入一张 256 阶灰度图,按照给定的卷积窗口计算卷积,并输出到文件中. ● 代码,使用 9 格的均值窗口,居然硬读写 .bmp 文件,算是了解一下该文件的具体格式,留作 ...

  2. AngularJS学习笔记(2)——与用户交互的动态清单列表

    与用户交互的动态清单列表 以我之前写的一个清单列表页面作为例子(MVC模式的清单列表效果),优化前代码如下: <!DOCTYPE html> <html ng-app="t ...

  3. leetcode921

    public class Solution { public int MinAddToMakeValid(string S) { Stack<char> ST = new Stack< ...

  4. Javascript 日期 加减

    //create the date var myDate = new Date(); //add a day to the date myDate.setDate(myDate.getDate() + ...

  5. Readme.MD 例子

    了解一个项目,恐怕首先都是通过其Readme文件了解信息.如果你以为Readme文件都是随便写写的那你就错了.github,oschina git gitcafe的代码托管平台上的项目的Readme. ...

  6. Zabbix 监控 Cisco ASA5525 流量

    简介: Zabbix 监控 Cisco ASA5525 网络接口流量 一.Zabbix 支持 SNMP.Cisco 开启 SNMP 二.测试 shell > snmpwalk -v 2c -c ...

  7. blocking network call

    [blocking network call] 阻塞的网络调用: 1.gethostbyname(): does not return until it has succeeded or failed ...

  8. MySQL 根据年、季度、月、周、日统计数据

    -- 计算每年订单的总价格 select date_format(t.order_time,'%Y') years,sum(t.order_amount) '总价格' from lf_order t ...

  9. Eclipse下生成.dll动态库及.a静态库使用 for Windows [z]

    以后的主要工作就是做库了,将我们的C或者C++写的接口做成库,给客户端使用,因此有必要知道库的使用和制作方法.主要是在Eclipse下搞了搞,公司用的是Carbide,也差不多.库做好了,用SVN已提 ...

  10. [Jmeter]Jmeter环境搭建

    Jmeter环境搭建 1.  拷贝 \\szpc1450\apache-jmeter-2.7 整个目录到本机(我是放在D盘,以下路径说明以D盘为例) 2.  拷贝\\szpc1450\Tools\au ...