无法通过电子邮件附加文件

时间:2015-02-23 07:53:29

标签: android email filepath email-attachments

你好,我试图附上一个文本文件,用电子邮件发送它,但是当打开电子邮件界面时,它说文件确实不存在,而它真的存在于手机存储上这里是代码

Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"MyMail@gmail.com"});
            i.putExtra(Intent.EXTRA_SUBJECT, "report gps location");
            i.putExtra(Intent.EXTRA_TEXT   , "body of email");
            i.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath() + "/folderName/file.txt"));
            try
            {
                 startActivity(Intent.createChooser(i, "Send mail..."));
            } 
            catch (android.content.ActivityNotFoundException ex)
            {
                 Toast.makeText(getBaseContext(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();
            }

0 个答案:

没有答案