展会信息港展会大全

Android email发送附件
来源:互联网   发布日期:2016-01-14 11:24:32   浏览:2183次  

导读:发送附件的六种方法:第一种方法:Uri uri = Uri.parse(mailto:sxh@oppo.com);Intent it = new Intent(Intent.ACTION_SENDTO, uri);startActivity(it);第二种方法:String[] toemail={sxh@oppo.com, ......

发送附件的六种方法:

第一种方法:

Uri uri = Uri.parse("mailto:sxh@oppo.com");

Intent it = new Intent(Intent.ACTION_SENDTO, uri);

startActivity(it);

第二种方法:

String[] toemail={"sxh@oppo.com", "mailtesst@163.com"};

String[] ccemail={"sxh@oppo.com", "mailtesst@163.com"};

String[] bccemail={"sxh@oppo.com", "mailtesst@163.com"};

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_EMAIL, toemail);

it.putExtra(Intent.EXTRA_CC, ccemail);

it.putExtra(Intent.EXTRA_BCC, bccemail);

it.putExtra(Intent.EXTRA_SUBJECT, "I love you baby!");

it.putExtra(Intent.EXTRA_TEXT, "The email body text");

it.setType("text/plain");

startActivity(it);

startActivity(Intent.createChooser(it, "请选择Email客户端软件"));

第三种方法:

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_EMAIL, "sxh@oppo.com");

it.putExtra(Intent.EXTRA_TEXT, "The email body text");

it.setType("text/plain");

startActivity(Intent.createChooser(it, "请选择Email客户端软件"));

第四种方法:

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_EMAIL, "sxh@oppo.com");

it.putExtra(Intent.EXTRA_SUBJECT, "html test");

it.putExtra(Intent.EXTRA_TEXT, http://www.android100.org/);

it.setType("text/html");

startActivity(Intent.createChooser(it, "请选择Email客户端软件"));

第五种方法:

//实现多个附件的添加,这种方式不是标准的做法,没有标准的做法,所以第三方软件不会支持

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");

//添加格式,前面字符串为附件的URI写法,后面表示此附件的类型;不能搞错,不能缺少

String szSelectedFiles[]={"file:///sdcard/ebook/CityCodes.xml", "text/xml","file:///sdcard/ebook/PhoneBookU.txt", "text/plain", "file:///sdcard/windy.gif", "image/gif"};

it.putExtra(Intent.EXTRA_STREAM, szSelectedFiles);

//以下这一句照抄,无论你的附件是什么类型的

it.setType("audio/mp3");

startActivity(Intent.createChooser(it, "请选择Email客户端软件"));

第六种方法:

//实现单个附件的添加

Uri uri = Uri.parse("file:///sdcard/mysong.mp3");

Intent it = new Intent(Intent.ACTION_SEND);

it.putExtra(Intent.EXTRA_STREAM, uri);

it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");

it.setType("audio/mp3");

startActivity(Intent.createChooser(it, "请选择Email客户端软件"));

赞助本站

人工智能实验室

相关热词: email 发送附件

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港