Programmatically Send an Email from Android App using Intent

Android Send Email from Activity
Android Send Email from Activity

Intents are messenger objects that are used to call Activities from a particular activity class. There are two types of Intents that you must know Explicit and Implicit Intents.

Implicit intents are used to call Activities that are defined within your project folder. To call other App Activity we need to use Explicit intents.

The code to send an email through your Android application from a Activity class is pretty simple. When this block of code is executed, a Dialog box is displayed with all the Email clients that are available on the device (e.g. Gmail, Mail, Outlook, Hotmail, Yahoomail etc), If no email client is found that you may get a pop-up saying "No Application can perform this action".


  1. Create an Intent object emailIntent with Intent.ACTION_SEND
  2. Set type as message/rfc822 i.e. for MIME type
  3. Use Intent.EXTRA_EMAIL as a key to putExtra and where you need to add the Email-ID of the recipient.
  4. Use Intent.EXTRA_SUBJECT key and pass the value as the Subject of Email.
  5. Similarly Intent.EXTRA_TEXT value is the Body of the Email.
  6. In a try catch block call startActivity()
  7. In the Catch block if ActivityNotFoundException has occurred, i.e No Email client is found, we display a Toast Message.
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL  , ""); // email id can be hardcoded too
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Hello");
emailIntent.putExtra(Intent.EXTRA_TEXT   , "This is the Body!");
  try {
          startActivity(Intent.createChooser(emailIntent, "Done!"));
    } catch (android.content.ActivityNotFoundException ex) {
      Toast.makeText(MainActivity.this, "No Email client found!!",
package com.code2care.example.emailexample;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends ActionBarActivity {
    private EditText emailID,emailSubject,emailBody;
    protected void onCreate(Bundle savedInstanceState) {
        emailID = (EditText) findViewById(;
        emailSubject = (EditText) findViewById(;
        emailBody = (EditText) findViewById(;
   public void sendEmail(View view) {
       Intent emailIntent = new Intent(Intent.ACTION_SEND);
       emailIntent.putExtra(Intent.EXTRA_EMAIL  , emailID.getText().toString());
       emailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSubject.getText().toString());
       emailIntent.putExtra(Intent.EXTRA_TEXT   , emailBody.getText().toString());
         try {
                 startActivity(Intent.createChooser(emailIntent, "Select a Email Client"));
           } catch (android.content.ActivityNotFoundException ex) {
             Toast.makeText(MainActivity.this, "No Email client found!!",


<RelativeLayout xmlns:android=""
    tools:context="com.code2care.example.toastasservice.ToastasService" >
        android:text="@string/hello_world" />

Hello there!,

You are using AdBlocker!

I am an independent developer trying to help fellow developers and students to resolve issues faced on a day-to-day basis, we 'Code to Care' . There is a lot of expenses involved in hosting and managing a website that's the reason we have ads.

A humble request to you to disable adBlocker on and support us pay our bills.

Cod2care - Line's of code for change.

To see contents reload page after unblocking
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities. Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, Tips-n-tricks, How Tos, Blogs, Articles, etc. on various platforms like Windows, Mac, Linux, Mobile platforms, etc. Technologies/Languages like Java, Objective-C, PHP, .Net, Android, SharePoint, jQuery, HTML, CSS, etc.