Skip to content

Instantly share code, notes, and snippets.

@mahdimortazavi
Created August 6, 2016 07:15
Show Gist options
  • Save mahdimortazavi/c092210b173fb93bfad0b374cbf419d1 to your computer and use it in GitHub Desktop.
Save mahdimortazavi/c092210b173fb93bfad0b374cbf419d1 to your computer and use it in GitHub Desktop.
send Email by Email app
private void sendEmail(){
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:" + "recipient@example.com"));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "My email's subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "My email's body");
try {
startActivity(Intent.createChooser(emailIntent, "Send email using..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Activity.this, "No email clients installed.", Toast.LENGTH_SHORT).show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment