Android Sending Email

Android Sending Email

Android Sending Email, this article is all about this word. You all is aware of what’s email.  We are able to also send our private documents also through emails.  Emails can be sent predicated on a user’s language settings.  Numerical messages   – e-mails that focus on ONLY amounts is normally an awful email and generally, most only numerical domains as well. Email is text messages distributed by digital means in one system user to 1 or even more recipients with a network

android sending email

Prior to starting Android Sending Email Activity, You need to know Email efficiency with intent, Objective is hauling data in one element of another element with-in the application form or beyond your application

In order to send an email from the application, you don’t need to implement an email client right from the start, but you may use a preexisting one like the default Android Email app provided from Google android, Gmail, Prospect, K-9 Email etc. For this function, we have to develop an activity that launches an email client, using an implicit Objective with the right data and action. In such a example, we will send an email from our application by using an Intent object that launches existing email clients.

Pursuing section explains various areas of our Intent subject necessary to send an email.

Intent Object – Action to Android sending Email

You shall use ACTION_SEND action to release an email consumer installed on your Google android phone. Following is easy syntax to generate an intent with ACTION_SEND action

Intent emailIntent = new Intent(Intent.ACTION_SEND);


Intent Object – Data/Type – Android Sending Email

To send an email you will need to designate mailto: as URI using setData() method and data type is to text/plain using setType() method the following



Intent Object – Extra – Android Sending Email

Android os has built-in support to increase, SUBJECT, CC, TEST and so on. fields which is often mounted on the purpose before mailing the objective to a aim for email client. You should use following extra domains in your email –

Extra Data & Description


A String[] having e-mail addresses that needs to be blind carbon copied.


A String[] having e-mail addresses that needs to be carbon copied.


A String[] retaining e-mail addresses that needs to be delivered to.


A frequent String that is from the Intent, used in combination with ACTION_SEND to provide an alternative solution to EXTRA_Text message as HTML formatted content material.


A continuous string retaining the desired subject matter type of a message.


A frequent CharSequence that is from the Intent, used in combination with ACTION_SEND to provide the literal data to be delivered.


A CharSequence dialog name to provide to an individual when used in combination with a ACTION_CHOOSER.

Here is a good example demonstrating you how to assign extra data to your intent

emailIntent.putExtra(Intent.EXTRA_EMAIL  , new String[]{"Recipient"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(Intent.EXTRA_TEXT   , "Message Body");


The out-put of above syntax is as below as  shown in image


Android Sending Email Example

Following android sending email example teaches you in sensible how to use intent object to establish Email customer to send a contact to the given recipients.

To send Email test out this android sending email example, you’ll need real Mobile device prepared with latest Android os OS(Android lollipop), otherwise you might get struggle with emulator which might not exactly work properly. Second you’ll need with an Email client like GMail(By default every android version having Gmail client App.

Steps       Description

1- You use Android studio to make an Android program and name it as Androdevelopment under a deal com.example.androdevelopment. While creating this task, ensure you Goal SDK and Compile With at the latest version of Google android SDK to work with higher degrees of APIs.

2- Modify src/ and add required code to care for sending email.

3- Modify design XML res/design/activity_main.xml add any GUI part if required. I’m adding a straightforward button to start Email Client.

4- Modify res/beliefs/strings.xml to establish required frequent values

5- Modify AndroidManifest.xml as given below

6-Run the application form to launch Google android emulator and confirm the consequence of the changes done in the application form.

Following is the content of the modified main activity file  src/com.example.Androdevelopment/

package com.example.androdevelopment;

import android.os.Bundle;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {
   protected void onCreate(Bundle savedInstanceState) {

      Button startBtn = (Button) findViewById(;
      startBtn.setOnClickListener(new View.OnClickListener() {
         public void onClick(View view) {
   protected void sendEmail() {
      Log.i("Send email", "");
      String[] TO = {""};
      String[] CC = {""};
      Intent emailIntent = new Intent(Intent.ACTION_SEND);
      emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
      emailIntent.putExtra(Intent.EXTRA_CC, CC);
      emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
      emailIntent.putExtra(Intent.EXTRA_TEXT, "Your Email");
      try {
         startActivity(Intent.createChooser(emailIntent, "Send mail..."));
         Log.i("Finished sending email...", "");
      catch (android.content.ActivityNotFoundException ex) {
         Toast.makeText(MainActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
   public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(, menu);
      return true;


Following will be the content of res/layout/activity_main.xml file −

<LinearLayout xmlns:android=""
   android:orientation="vertical" >
      android:text="Sending Mail Example"
      android:textSize="30dp" />
      android:text="Andro Development"
      android:layout_alignEnd="@+id/imageButton" />
      android:layout_centerHorizontal="true" />


Following will be the content of res/values/strings.xml to define two new constants −

<?xml version="1.0" encoding="utf-8"?>
   <string name="app_name">Androdevelopment</string>
   <string name="hello_world">Hello world!</string>
   <string name="action_settings">Settings</string>
   <string name="compose_email">Compose Email</string>


Following is the default content of AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
   android:versionName="1.0" >
      android:theme="@style/AppTheme" >
         android:label="@string/app_name" >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />


Let’s make an effort to run our androdevelopment app. I suppose you have linked your actual Google android Mobile device with your personal computer. To perform the app from Android Studio room, wide open one of your project’s activity and click Run Eclipse Run Icon  from the toolbar. Prior to starting your application, Android os studio installer will screen following window to choose a choice where you want to perform your Android request.Choose your mobile device as a choice and check your mobile device that will screen pursuing display screen

android sending email

Now click Compose Email button to list down all the installed email clients. From your list, you can pick one of email clients to send your email. I’ll use Gmail customer to send my email that may have all the provided defaults domains available as shown below. Here From: will be default email ID you have listed for your Android os device.

android sending email

You can adjust either of the given default domains and lastly use send email button to send your email to the talked about recipients.