我试图在Android上使用本机电子邮件客户端发送电子邮件 电话。
我尝试过以下方法为邮件添加附件...
方法 - 1
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/abc.jpg"));
方法2
将图像作为正文内容发送---
sendIntent.putExtra(Intent.EXTRA_TEXT, "<HTML><BODY><b><IMG**SRC=
\"data:image/jpeg;base64," + <imagepath> + "\"**alt = \"**pleaseview this
image\"/></b></BODY></HTML>");
我可以手动成功附加图像,但是当我尝试时 以编程方式附加和发送邮件是没有发送的 attachement。
如果有办法发送附件,请告诉我 以编程方式使用电子邮件客户端
答案 0 :(得分:15)
我认为你的问题是你没有把文件路径放在正确的位置。
以下适用于我:
Intent i = new Intent(Intent.ACTION_SEND);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setType("image/jpg");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Pictures/
image.jpg"));
startActivity(i);
请注意,文件路径有3“/”,前两个用于“file://”标头,另一个是因为sdcard dir位于文件系统的根目录下,在linux中是“/”。
答案 1 :(得分:1)
我相信您使用的Uri
不正确。我试过file:///mnt/sdcard/
并且工作得很好。