尝试发送带有附件的邮件 - 我不知道为什么这段代码不起作用..邮件没有发送
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"));
}
答案 0 :(得分:1)
以下是我将文件作为附件发送的内容:
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(“text / plain”);当我尝试别人时,命令不起作用。