Android通过Intent发送电子邮件含附件
来源:互联网 发布:和利时dcs编程指令详解 编辑:程序博客网 时间:2024/09/21 09:26
如何在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通过Intent发送电子邮件含附件
- Android通过Intent发送电子邮件含附件
- Android通过Intent发送电子邮件含附件
- Android通过Intent发送带附件的电子邮件
- Android 系列 4.3使用附件发送电子邮件
- Android 代码发送email含附件
- android APP通过jmail实现发送电子邮件
- C# 发送电子邮件(含附件)用到的类 system.web.mail
- C# 发送电子邮件(含附件)用到的类 system.web.mail
- C# 发送电子邮件(含附件)用到的类 system.web.mail
- C# 发送电子邮件(含附件)用到的类 system.Net.mail
- C# 发送电子邮件(含附件)用到的类 system.web.mail
- Android通过intent发送彩信
- 通过电子邮件发送图片
- 通过PHPMailer发送电子邮件
- android 应用组件[通用 Intent---撰写带有可选附件的电子邮件] 十
- 用 VFP 发送带附件的电子邮件
- 用PHP发送有附件的电子邮件
- Android Sensor传感器系统架构初探
- inline函数
- 我想你了,你可曾知道?
- IE8下面不能启动VS2005的调试
- 手机实名制要过电信[内鬼]关
- Android通过Intent发送电子邮件含附件
- Linux之GCC命令 -- 解析GCC编译的四个过程
- C++语言机制之多态性 与 代码重用机制的一种工具之模板 小结
- win 7 必备 1
- 有关js的一点笔记(alert乱码问题)
- asp.net动态加载ascx用户控件
- 论模式对话框与非模式对话框
- win 7 必备 2
- Java的ClassLoader机制