Search code examples
androidbuttongmail

Android open emailclient programmatically


Is it possible to open an emailclient such as gmail when I click a button in my app?


Solution

  • Yes. You can launch it via Intents.

    Intent i = new Intent(Intent.ACTION_SEND);
    i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ emailAddress });
    i.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    i.putExtra(android.content.Intent.EXTRA_TEXT, text);
    startActivity(Intent.createChooser(i, "Send email"));