android:将文件附加到邮件
作者:互联网
我有这个发送邮件的代码:
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, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(BladeActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
如何将此文件附加到此邮件:/sdcard/MyFile.csv
谢谢,
解决方法:
试试这个:
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/MyFile.csv"));
并确保您具有访问外部存储所需的权限.
标签:android,android-intent,email-attachments 来源: https://codeday.me/bug/20190609/1207798.html