WP8.1StoreApp(WP8.1RT)---发送邮件和短信
在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)---发送邮件和短信的更多相关文章
- WP8.1StoreApp(WP8.1RT)---本地Toast
WP7/8中的Toast是不能在前台弹出的. WP8.1StoreApp可以利用Win8中的方式: private void Toast(string title,string content) { ...
- WP8.1StoreApp(WP8.1RT)---第三方启动
8.1的协议和wp8是相互通用的 被启动: 相比较wp8而言,基本变化不大,但添加方式更直观了 1:打开Package.appxmanifest 2:切换到"声明"选项卡 3:左侧 ...
- WP8.1StoreApp(WP8.1RT)---MessageBox与MessageDialog
在WP7和WP8中,MessageBox是跟WinForm中一样常用的对话框,但是有一个显著的缺点,就是WP7/8中默认的MessageBox是阻塞线程的.也许是由于这个原因,WP8.1/Win8中采 ...
- WP8.1StoreApp(WP8.1RT)---添加推送功能和获取系统信息
添加推送通知 1:Package.appxmanifest中的声明添加后台任务的推送通知权限 2:var channel = await PushNotificationChannelManager. ...
- WP8.1StoreApp(WP8.1RT)---SystemTray的变化
原Microsoft.Phone.Shell中的SystemTray,已经改到Windows.UI.ViewManagement中StatusBar了. 只能在代码中设置相关属性. 如: 1 2 3 ...
- ios开发——实用技术篇Swift篇&地址薄、短信、邮件
//返回按钮事件 @IBAction func backButtonClick() { self.navigationController?.popViewControllerAnimated(tru ...
- 一百四十七:CMS系统之celery实现邮件和短信异步发送
celery工作原理 celery官方文档:https://docs.celeryproject.org/en/latest/ 安装:pip install celery windows下还需安装ev ...
- a标签的妙用-拨打电话、发送短信、发送邮件
前端时间在做手机WAP网站时,遇到需要点击页面上显示的电话号能直接拨号的需求,查找资料发现可以使用html的a标签完美实现该需求!记录下来以备后用...... 目前主流手机浏览器对H5的支持已经很不错 ...
- html拨打电话、发送短信、发送邮件的链接写法
拨打电话 <a href="tel:88888888">呼叫</a> 发送短信 <a href="sms:88888888"> ...
随机推荐
- gridview发布后,编辑改为edit 原因是未安装 dotNetFx40LP_Full_x86_x64zh-Hans中文语言包
https://www.microsoft.com/zh-cn/download/details.aspx?id=3324
- 使用libcurl显示下载进度
使用libcurl显示下载进度 http://blog.csdn.net/zhouzhenhe2008/article/details/53876622
- pac (PAC(Proxy Auto Config) 是一个 Script;经由编写这个 Script,我们可以让系统判断在怎么样的情形下,要利用哪一台 Proxy 来进行联机。)
PAC自动代理文件格式,教你如何写PAC文件 PAC文件格式 PAC文件是纯文本格式的,实际上就是JavaScript文件.Chrome/Chromium的扩展Switchy!的"Auto ...
- delphi 工具
http://blog.csdn.net/maxwoods/article/category/1285993
- Node.js中的express框架获取http参数
最近本人在学习开发NodeJs,使用到express框架,对于网上的学习资料甚少,因此本人会经常在开发中做一些总结. express获取参数有三种方法:官网介绍如下 Checks route para ...
- Visual Studio 2013 osg
1>------ Rebuild All started: Project: ZERO_CHECK, Configuration: Debug x64 ------1> Checking ...
- 使用IntelliJ IDEA,gradle开发Java web应用步骤
最近 正在学习gradle构建工具的使用,看了一堆的文档,有点一知半解,索性动作实践一把,在以后的自己的项目中尝试使用看看.目前手头用的是IntelliJ IDEA 14,搭建了一天终于明白怎么集成g ...
- NOSQL之Redis、MongDB、Habase、Cassandra的介绍与比较
一.Redis介绍 1.1Redis优点 (1)Redis拥有非常丰富的数据结构: (2)Redis提供事务的功能,可以保证一串命令的原子性,中间不会被任何打断. (3)数据存储在内存中,读写 ...
- Golang之函数练习
小例题: package main import "fmt" /* 函数练习, 可变参数使用 写一个函数add 支持1个或多个int相加,并返回相加结果 写一个函数concat,支 ...
- requests.session之set trust_env to disable environment searches for proxies
import requests s = requests.Session() s.trust_env = False This will prevent requests getting any in ...