AndroidIntent:发送带有图像附件的电子邮件 [英] AndroidIntent: Send an email with image attachment
本文介绍了AndroidIntent:发送带有图像附件的电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
收件人正在接收电子邮件,但没有附件.这是代码,有没有高手知道我哪里出错了?
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)));
我明白了:
file://附件路径必须指向 file://sdcard.忽略附件 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.
推荐答案
试试下面的代码...
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..."));
这篇关于AndroidIntent:发送带有图像附件的电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文