0

I want to send email from Android virtual machine to my gmail account. Problem: but on pressing send button I am getting:

"No application can perform this action"

Here is my code:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("audio/mp3");
//sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");
//sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/download/test.mp3")); 
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(GlobalVariable.getstrEmail())); 
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
startActivity(Intent.createChooser(sendIntent, "Title:"));
Cœur
  • 37,241
  • 25
  • 195
  • 267
Android
  • 8,995
  • 9
  • 67
  • 108

3 Answers3

3

Try it on a real device itself, it should work. And you need to change the type:

final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"email@example.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "body text");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Cfr
  • 5,092
  • 1
  • 33
  • 50
Hades
  • 3,916
  • 3
  • 34
  • 74
1

This can help...

  Intent openEmailIntent = new Intent(android.content.Intent.ACTION_SEND);
  openEmailIntent.setType("plain/text");
  openEmailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                           new String[{"zoombie@gmail.com"});
  openEmailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"subject you want");
  openEmailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Any body ");
  this.startActivity(Intent.createChooser(openEmailIntent,"Sharing via Email"));
Dan Burton
  • 53,238
  • 27
  • 117
  • 198
Zoombie
  • 3,590
  • 5
  • 33
  • 40
0

try this....

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);        
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{emailaddress});                                        
            startActivity(Intent.createChooser(emailIntent, "Send mail..."));
Kakey
  • 3,936
  • 5
  • 29
  • 45