安卓\意图:发送一封电子邮件,图像附件 [英] Android\Intent: Send an email with image attachment
本文介绍了安卓\意图:发送一封电子邮件,图像附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
该电子邮件被接收在由接收者,但没有附件。这里是code,哪位高手知道在哪里我做错什么了?
The email is being received on by the recipient, but without the attachment. Here is the code, any expert knows where did I go wrong?
Intent messageIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { "mymailgmail.com" };
messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
...
messageIntent.setType("image/jpeg");
File downloadedPic = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "MyApp.jpg");
messageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
startActivity(Intent.createChooser(messageIntent, getResources().getString(R.string.chooser_pic)));
我得到:
文件://附件路径必须指向文件:// SD卡。忽略附件文件://...file名是MyApp.jpg
file:// attachment path must point to file://sdcard. Ignoring attachment file://...file name is MyApp.jpg
我没有得到的图像,只有上面的文字信息。谢谢你。
I am not getting image, only above text message. Thanks.
推荐答案
尝试下面code ...
Try below code...
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("application/image");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Test Subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "From My App");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/Myimage.jpeg"));
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
这篇关于安卓\意图:发送一封电子邮件,图像附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文