Trying to attach a file from SD Card to email

Posted by Chrispix on Stack Overflow See other posts from Stack Overflow or by Chrispix
Published on 2009-02-25T21:23:04Z Indexed on 2010/06/11 7:12 UTC
Read the original article Hit count: 350

Filed under:
|
|
|

I am trying to launch an Intent to send an email. All of that works, but when I try to actually send the email a couple 'weird' things happen.

here is code

            Intent sendIntent = new Intent(Intent.ACTION_SEND);
          	sendIntent.setType("image/jpeg");
        	sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Photo");
        	sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/dcim/Camera/filename.jpg"));
        	sendIntent.putExtra(Intent.EXTRA_TEXT, "Enjoy the photo");
        	startActivity(Intent.createChooser(sendIntent, "Email:"));

So if I launch using the Gmail menu context It shows the attachment, lets me type who the email is to, and edit the body & subject. No big deal. I hit send, and it sends. The only thing is the attachment does NOT get sent.

So. I figured, why not try it w/ the Email menu context (for my backup email account on my phone). It shows the attachment, but no text at all in the body or subject. When I send it, the attachment sends correctly. That would lead me to believe something is quite wrong. Do I need a new permission in the Manifest launch an intent to send email w/ attachment? What am I doing wrong?

© Stack Overflow or respective owner

Related posts about android

Related posts about email