Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSV文件附件无法在Android中与电子邮件一起发送_Android_Email Attachments - Fatal编程技术网

CSV文件附件无法在Android中与电子邮件一起发送

CSV文件附件无法在Android中与电子邮件一起发送,android,email-attachments,Android,Email Attachments,我正在创建一个应用程序,其中生成了一个.csv文件。现在我使用电子邮件发送了此文件,但收到的邮件没有将我的文件作为附件。我的代码如下 请帮帮我,我哪里做错了 我试过这个链接 按钮输出 File csvDirectory= new File(Environment.getExternalStorageDirectory(),"CSVFiles"); if(!csvDirectory.exists()) {`enter code here`

我正在创建一个应用程序,其中生成了一个.csv文件。现在我使用电子邮件发送了此文件,但收到的邮件没有将我的文件作为附件。我的代码如下

请帮帮我,我哪里做错了

我试过这个链接

按钮输出

File    csvDirectory= new File(Environment.getExternalStorageDirectory(),"CSVFiles");
        if(!csvDirectory.exists())
        {`enter code here`
            csvDirectory.mkdirs();
        }
        final File csv= new File(csvDirectory, "firstcsv.csv");
        try{
             if(!csv.exists())
             {
              csv.createNewFile();
              }
             path=csv.getPath();

export.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                sendMail();

            }
        });

public void sendMail()
    {
        File f= new File(path);
        u1=Uri.fromFile(f);
        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Person Details");
        sendIntent.putExtra(Intent.EXTRA_STREAM, u1);
        sendIntent.setType("text/html");
        startActivity(sendIntent);
    }
在sendMail()中尝试此操作,而不是在text/html中尝试

sendIntent.setType("text/csv ");