android gmail 添加附件(转载)
来源:互联网 发布:选数码产品软件 编辑:程序博客网 时间:2024/05/01 15:58
sendMail1.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
//OK,1
/* Uri uri = Uri.parse("mailto:sxh@oppo.com");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);*/
//OK,2
// 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客户端软件"));
//OK,3
// 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客户端软件"));
//OK,6
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.tianya.cn/publicforum/content/stocks/1/776130.shtml");
it.setType("text/html");
startActivity(Intent.createChooser(it, "请选择Email客户端软件"));
}
});
Button sendMail2 = (Button)findViewById(R.id.sendMail2);
sendMail2.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
//OK,5 实现多个附件的添加,这种方式不是标准的做法,没有标准的做法,所以第三方软件不会支持
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客户端软件"));
//OK,4 实现单个附件的添加
// 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客户端软件"));
}
});sendMail1.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
//OK,1
/* Uri uri = Uri.parse("mailto:sxh@oppo.com");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);*/
//OK,2
// 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客户端软件"));
//OK,3
// 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客户端软件"));
//OK,6
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.tianya.cn/publicforum/content/stocks/1/776130.shtml");
it.setType("text/html");
startActivity(Intent.createChooser(it, "请选择Email客户端软件"));
}
});
Button sendMail2 = (Button)findViewById(R.id.sendMail2);
sendMail2.setOnClickListener(new OnClickListener(){
public void onClick(View v)
{
//OK,5 实现多个附件的添加,这种方式不是标准的做法,没有标准的做法,所以第三方软件不会支持
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客户端软件"));
//OK,4 实现单个附件的添加
// 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客户端软件"));
}
});
Android通过Intent发送电子邮件含附件(另附)
如何在Android系统中发送带附件的电子邮件呢? 其实通过Intent可以很方便的发送Email,只需要短短10行代码就可以处理,这里Android开发网就以在sdcard上的android123.cwj文件为例,通过Intent来发送电子邮件。完整代码如下
File file = new File("/sdcard/android123.cwj"); //附件文件地址
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra("subject", file.getName()); //
intent.putExtra("body", "android123 - email sender"); //正文
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); //添加附件,附件为file对象
if (file.getName().endsWith(".gz")) {
intent.setType("application/x-gzip"); //如果是gz使用gzip的mime
} else if (file.getName().endsWith(".txt")) {
intent.setType("text/plain"); //纯文本则用text/plain的mime
} else {
intent.setType("application/octet-stream"); //其他的均使用流当做二进制数据来发送
}
startActivity(intent); //调用系统的mail客户端进行发送
- android gmail 添加附件(转载)
- Android 获得Gmail附件文件名的方法
- android 短信添加附件
- Android GMail/EMail附件读取/存储简析
- Android GMail/EMail附件读取/存储简析
- Gmail 附件类型限制
- android 彩信附件添加删除
- (16)添加附件、删除附件
- 无刷新上传文件以及类Gmail附件添加方式的实现
- 模访gmail的附件上传
- 添加附件、删除附件
- 添加附件
- 添加附件
- 添加附件
- Android 为按键添加声音(转载)
- gmail 邮箱附件大小 突破10M
- 评gmail不能发送exe附件
- 测试Gmail附件链接是否长期有效
- Linux autotools使用简介
- 变态的东东
- 2066-多源多汇最短路
- wince 6.0中的硬件操作问题
- 企业库学习:异常处理模块
- android gmail 添加附件(转载)
- php 魔法函数解释
- java 字符串里面尖括号的转码
- uiwebview缩放引起崩溃
- 命令行GBD前端—CGDB
- 如何分析网页元素并进行相应处理
- ListView-更改控件显示样式
- Putty: network error software caused connection abort
- test writeblog