Android Email

In this thread lets look at several options, libraries and examples for sending email in android.

You can send email just via intents. You need to chose an action based on whether an attachment is part of the email or not.

  1. ACTION_SENDTO (for no attachment) or
  2. ACTION_SEND (for one attachment) or
  3. ACTION_SEND_MULTIPLE (for multiple attachments)

The MIME Type can be:

  1. "text/plain"
  2. “*/*”

The Extras can be:

  1. Intent.EXTRA_EMAIL – A string array of all “To” recipient email addresses.
  2. Intent.EXTRA_CC – A string array of all “CC” recipient email addresses.
  3. Intent.EXTRA_BCC – A string array of all “BCC” recipient email addresses.
  4. Intent.EXTRA_SUBJECT – A string with the email subject.
  5. Intent.EXTRA_TEXT – A string with the body of the email.
  6. Intent.EXTRA_STREAM – A Uri pointing to the attachment. If using the ACTION_SEND_MULTIPLE –  action, this should instead be an ArrayList containing multiple  Uri objects.

Here is a Kotlin example to send email:

fun composeEmail(addresses: Array<String>, subject: String, attachment: Uri) {
    val intent = Intent(Intent.ACTION_SEND).apply {
        type = "*/*"
        putExtra(Intent.EXTRA_EMAIL, addresses)
        putExtra(Intent.EXTRA_SUBJECT, subject)
        putExtra(Intent.EXTRA_STREAM, attachment)
    if (intent.resolveActivity(packageManager) != null) {

Here is a Java Example to send email in android:

public void composeEmail(String[] addresses, String subject, Uri attachment) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_EMAIL, addresses);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_STREAM, attachment);
    if (intent.resolveActivity(getPackageManager()) != null) {


Proceed below to see more options for sending email. Feel free to contribute more examples.


Related Concepts


1 Example

  1. EmailIntentBuilder

    This an Android Library for the creation of SendTo Intents with mailto: URI.

    Step 1 – Installation

    Install the library by adding the following statement in your build.gradle  file:

    implementation 'de.cketti.mailto:email-intent-builder:2.0.0'


    Step 2

    Then set the appropriate fields to be sent:

            .subject("Message from an app")
            .body("Some text here")


    Here is a full example to use this library to send email:


    import android.os.Bundle;
    import android.text.TextUtils;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.EditText;
    import de.cketti.mailto.EmailIntentBuilder;
    public class MainActivity extends AppCompatActivity {
        private View mainContent;
        private EditText emailTo;
        private EditText emailCc;
        private EditText emailBcc;
        private EditText emailSubject;
        private EditText emailBody;
        protected void onCreate(Bundle savedInstanceState) {
            mainContent = findViewById(;
            emailTo = findViewById(;
            emailCc = findViewById(;
            emailBcc = findViewById(;
            emailSubject = findViewById(;
            emailBody = findViewById(;
            findViewById( -> sendEmail());
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(, menu);
            return true;
        public boolean onOptionsItemSelected(MenuItem item) {
            if (item.getItemId() == {
            return true;
        private void sendFeedback() {
            boolean success = EmailIntentBuilder.from(this)
            if (!success) {
                Snackbar.make(mainContent, R.string.error_no_email_app, Snackbar.LENGTH_LONG).show();
        void sendEmail() {
            String to = emailTo.getText().toString();
            String cc = emailCc.getText().toString();
            String bcc = emailBcc.getText().toString();
            String subject = emailSubject.getText().toString();
            String body = emailBody.getText().toString();
            EmailIntentBuilder builder = EmailIntentBuilder.from(this);
            try {
                if (!TextUtils.isEmpty(to)) {
                if (!TextUtils.isEmpty(cc)) {
                if (!TextUtils.isEmpty(bcc)) {
                if (!TextUtils.isEmpty(subject)) {
                if (!TextUtils.isEmpty(body)) {
                boolean success = builder.start();
                if (!success) {
                    Snackbar.make(mainContent, R.string.error_no_email_app, Snackbar.LENGTH_LONG).show();
            } catch (IllegalArgumentException e) {
                String errorMessage = getString(R.string.argument_error, e.getMessage());
                Snackbar.make(mainContent, errorMessage, Snackbar.LENGTH_LONG).show();



    Here are the links:

    1. Directly Download the code here.
    2. Browse through the code or read more here.
    3. Follow Author here.

Share an Example

Share an Example

What is the capital of Egypt? ( Cairo )