Intent.EXTRA_EMAIL does not fill in the To

I am trying to use intent to send an email from my application, but the To field of the email will not be filled. If I add code to fill in a topic or text, they work fine. Just the To field will not be filled.

I also tried changing the type to "text / plain" and "text / html", but I have the same problem. Can anyone help?

public void Email(){ Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("message/rfc822"); //set the email recipient String recipient = getString(R.string.IntegralEmailAddress); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL , recipient); //let the user choose what email client to use startActivity(Intent.createChooser(emailIntent, "Send mail using...")); } 

The email client I'm trying to use is Gmail

+74
android android-intent
Feb 01 2018-12-12T00:
source share
3 answers

I think you do not pass recipient as array of string

he should be like

 emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "someone@gmail.com" }); 
+181
Feb 01 '12 at 14:13
source share

Use this

 public void Email(){ // use this to declare your 'recipient' string and get your email recipient from your string xml file Resources res = getResources(); String recipient = getString(R.string.IntegralEmailAddress); Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("message/rfc822"); //set the email recipient emailIntent.putExtra(Intent.EXTRA_EMAIL, recipient); //let the user choose what email client to use startActivity(Intent.createChooser(emailIntent, "Send mail using...")); ``} 

This will work :)
This is what android documentation says about Intent.Extra_Email
-Bind an array of all recipient email addresses. So you have to feed the line correctly. You can read more here.
http://developer.android.com/guide/components/intents-common.html#Email and here http://developer.android.com/guide/topics/resources/string-resource.html Or use the ACTION_SENDTO action and enable data scheme "mailto:". For example:

 Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse("mailto:")); // only email apps should handle this intent.putExtra(Intent.EXTRA_EMAIL, addresses); intent.putExtra(Intent.EXTRA_SUBJECT, subject); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } 
+4
Jan 13 '16 at 10:07 on
source share
 private void callSendMeMail() { Intent Email = new Intent(Intent.ACTION_SEND); Email.setType("text/email"); Email.putExtra(Intent.EXTRA_EMAIL, new String[] { "me@gmail.com" }); Email.putExtra(Intent.EXTRA_SUBJECT, "Feedback"); startActivity(Intent.createChooser(Email, "Send mail to Developer:")); } 
+1
Oct 01 '15 at 9:39 on
source share



All Articles