Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ACTION_SENDTO does not work

I want to send out an email from my app. So I used the following code.

String uriText = "[email protected]" + "?subject=" + URLEncoder.encode("Subject") + "&body=" + URLEncoder.encode("some text here");
Uri uri = Uri.parse(uriText);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent, "Send Email"));

I have configured both my Gmail and EMail applications. I tested on my Nexus S (JellyBean) and HTC T-Mobile G2 (GingerBread). Both of them shows "No apps can perform this action.".

Does anyone have idea what's wrong here?

like image 258
Karthik Andhamil Avatar asked Dec 21 '12 17:12

Karthik Andhamil


3 Answers

If you are going to use ACTION_SENDTO, the Uri should use the mailto: or smsto: scheme. So, try mailto:[email protected].

like image 153
CommonsWare Avatar answered Nov 14 '22 20:11

CommonsWare


if you are using Intent.setData for sending email then change your code as:

String uriText = "mailto:[email protected]" +
                 "?subject=" + URLEncoder.encode("Subject") + 
                 "&body=" + URLEncoder.encode("some text here");
Uri uri = Uri.parse(uriText);
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
startActivity(Intent.createChooser(sendIntent, "Send Email"));
like image 38
ρяσѕρєя K Avatar answered Nov 14 '22 19:11

ρяσѕρєя K


Uri should be "mailto"

 Intent intent = new Intent(Intent.ACTION_SENDTO);  
 intent.setData(Uri.parse("mailto:"));  
 intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"[email protected]"});  
 intent.putExtra(Intent.EXTRA_SUBJECT,"Order summary of Coffee");
 intent.putExtra(Intent.EXTRA_TEXT,BodyOfEmail);

 if(intent.resolveActivity(getPackageManager())!=null) {
            startActivity(intent);
        }
like image 1
zeeshan ahmad Avatar answered Nov 14 '22 19:11

zeeshan ahmad