// 附件文件地址
    String fileName = items.get(arg2).get(NAME);
    File file = new File(Environment.getExternalStorageDirectory(), fileName);
    // 启动系统邮件
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra("subject", file.getName());
    // 正文
    intent.putExtra("body", fileName);
    // 添加附件,附件为file对象
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    // 如果是gz使用gzip的mime
    if (file.getName().endsWith(".gz")) {
    intent.setType("application/x-gzip");
    }
    // 纯文本则用text/plain的mime
    else if (file.getName().endsWith(".txt")) {
    intent.setType("text/plain");
    }
    // 其他的均使用流当做二进制数据来发送
    else {
    intent.setType("application/octet-stream");
    }
    // 调用系统的mail客户端进行发送。
    startActivity(intent);

更多相关文章

  1. android 调用系统的图片选择
  2. ffmpeg3.3 编译 android 系统版本 32位 和64 位 动态库
  3. Android property系统分析
  4. Android判断网络是否可用,调用系统网络设置
  5. 非常不错的资金管理系统android版客户端源码
  6. PHP如何检测手机是什么系统?
  7. 调用android系统自带的功能

随机推荐

  1. 【Android】glide:3.7.0->4.8.0 升级导入
  2. Android app widget 支持的Layout和widge
  3. Settings中蓝牙连接流程
  4. Activity设置透明背景
  5. Java/Android倒计时(开始,暂停,恢复,停止)
  6. Delphi Android USB声明文件
  7. Android周学习Step By Step(7)--Activity简
  8. Android studio 修改SDK路径
  9. android的socket程序中conn.getResponseC
  10. Android SDK not found 的解决方案