简体   繁体   English

如何将SD卡中的图像附加到电子邮件?

[英]How to attach an image from SD Card to an email?

I am trying to attach an image from SD Card to an email (from my app to Gmail app). 我正在尝试将SD卡中的图像附加到电子邮件(从我的应用程序发送到Gmail应用程序)。

Every time I try, I select Gmail app and it closes, it doesn't attach the file. 每次尝试时,我都会选择Gmail应用程序并关闭,但它不会附加文件。

Let's say the image path is: /sdcard/DCIM/Snapseed/Snapseed4.jpg . 假设图片路径为: /sdcard/DCIM/Snapseed/Snapseed4.jpg This is the code I am using to send the email: 这是我用来发送电子邮件的代码:

Intent emailintent2 = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailintent2.setType("image/*");
emailintent2.putExtra(Intent.EXTRA_EMAIL, emailaddress2);
emailintent2.putExtra(Intent.EXTRA_SUBJECT, CorAsunto);
emailintent2.putExtra(Intent.EXTRA_TEXT, message2);

Uri uris = Uri.fromFile(new File(Environment.getExternalStorageDirectory()
        + "/DCIM/Snapseed/Snapseed4.jpg"));

emailintent2.putExtra(Intent.EXTRA_STREAM, uris);
startActivity(emailintent2);
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/plain");
    emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    emailIntent.setType("image/jpeg");
    emailIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("SDCARD IMAGE PATH"));
    startActivity(Intent.createChooser(emailIntent,"Share image using"));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM