0

I am developing an app in which I want to click Image and automatically after capturing image, the app should send the picture to mail.

Intent shareIntent = new Intent(Intent.ACTION_SEND); 
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imgSaved));
shareIntent.setType("image/*"); 
startActivity(Intent.createChooser(shareIntent, "Share Image"));
nobalG
  • 4,544
  • 3
  • 34
  • 72
abhi
  • 154
  • 16
  • show us the code which you tried?? – Naufal Nov 08 '14 at 06:05
  • Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imgSaved)); shareIntent.setType("image/*"); startActivity(Intent.createChooser(shareIntent, "Share Image")); – abhi Nov 08 '14 at 06:15

2 Answers2

1

You need to create an intent which will be fired on selection of the image

Intent intent = new Intent(android.content.Intent.ACTION_SEND); 
intent.setType("application/image");
intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{strEmail}); 
intent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Any subject you want to give"); 
intent.putExtra(android.content.Intent.EXTRA_TEXT, "text you want"); 
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///mnt/sdcard/imageYouSelected.jpeg"));
startActivity(Intent.createChooser(emailIntent, "sending youer email"));

OR You can use the JAVA API approach like here

Community
  • 1
  • 1
nobalG
  • 4,544
  • 3
  • 34
  • 72
  • Using your code, will attach the picture on Gmail, but I want that the picture should be send automatically to the given Gmail. – abhi Nov 08 '14 at 06:18
  • [What about JAVA api approach?](http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-built-in-a) – nobalG Nov 08 '14 at 06:23
0

try like this may help you,

Intent shareIntent = new Intent(Intent.ACTION_SEND); 
shareIntent.putExtra(Intent.EXTRA_EMAIL,
                new String[] { "aa@gmail.com" });
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "text of email"); 
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imgSaved));
shareIntent.setType("image/*"); 
startActivity(Intent.createChooser(shareIntent, "Share Image"));
Akash Moradiya
  • 3,318
  • 1
  • 14
  • 19
  • thanks for the answer, but I want that that Image should be send on Mail automatically without any user Interaction. – abhi Nov 08 '14 at 06:37