Android 为什么发送邮件对我的代码不起作用?

Android 为什么发送邮件对我的代码不起作用?,android,Android,正在尝试发送带有附件的邮件-我不知道为什么此代码不起作用。。邮件没有发送 public void SendMailWithAttached(String fileToSend, String mailToSend) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("vnd.android.cursor.dir/email"); sharingIntent.pu

正在尝试发送带有附件的邮件-我不知道为什么此代码不起作用。。邮件没有发送

public void SendMailWithAttached(String fileToSend, String mailToSend)
{  
    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
    sharingIntent.setType("vnd.android.cursor.dir/email");
    sharingIntent.putExtra(Intent.EXTRA_EMAIL, fileToSend);
    sharingIntent.putExtra(Intent.EXTRA_STREAM,mailToSend);
    sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");

    startActivity(Intent.createChooser(sharingIntent, "Send email"));

}

以下是我如何将文件作为附件发送:

File effFile = new File(toPath, files[0]);
Uri effU = Uri.fromFile(effFile);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_STREAM, effU);
startActivity(Intent.createChooser(i, "Email:"));

i.setType(“文本/普通”);当我尝试其他命令时,命令不起作用

您是否有任何错误?您是否安装了一些邮件发件人?如果不是,您的意图选择器将无法工作。没有错误-我已经安装了mail senderSo,问题在于您的源代码中。您想做什么?只需附加文件(将文件位置指定为param)并发送