tags:

views:

18

answers:

1
Intent emailIntent = new Intent(Intent.ACTION_SEND);
Uri U=Uri.parse("c:/logo.png"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"[email protected]");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");
emailIntent.setType("image/png");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,U);
startActivity(Intent.createChooser(emailIntent, "Email:"));

I am using this kind of coding for attach image file,this code sent attach with email,but that attach file dose not contain no image,what can i do for display attach image file.

+1  A: 

Hey... it seems you are trying to attach something that is inside your C: drive. That's not possible :) You can only attach images on the sdcard folder of the handset. For instance:

Intent emailIntent = new Intent(Intent.ACTION_SEND);
Uri U=Uri.parse("file:///sdcard/logo.png");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,"[email protected]");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message");
emailIntent.setType("image/png");
emailIntent.putExtra(android.content.Intent.EXTRA_STREAM,U);
startActivity(Intent.createChooser(emailIntent, "Email:"));

To know where the sdcard folder is mounted, you use the Environment.getExternalStorageDirectory() method.

Cristian