Skip to content

Instantly share code, notes, and snippets.

@seemike
Last active December 22, 2015 06:58
Show Gist options
  • Save seemike/6434660 to your computer and use it in GitHub Desktop.
Save seemike/6434660 to your computer and use it in GitHub Desktop.
Android: send an email. Lets the user select the email app if there is more than one
/**
* send an email. Lets the user select the email app if there is more than one
* @param to
* @param subject
* @param body
*/
void email(String to, String subject, String body){
//mailto url
to = to == null ? "" :to;
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" +to +"?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(body)));
startActivity(Intent.createChooser(intent, getString(R.string.send_email)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment