Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
Emails in Android
Intent Object for Sending Email
For Action In Intent Object
For MIME Type In Intent Object
For Extras In Intent Object
Example Application
Key Takeaways 
Last Updated: Mar 27, 2024

Sending Emails In Android

Author Akshit Pant
0 upvote
Master Python: Predicting weather forecasts
Ashwin Goyal
Product Manager @


Email is the electronic transmission of messages from one system user to one or more recipients through a network.

In this blog, we will be learning about how to send an email on Android, Action intent type, MIME meaning, and much more.

Before jumping directly on how Android Studio does this, first knowing the basic knowledge of Kotlin and how to use it is strongly recommended.

So, let us start reading about how sending of emails works on Android.

Emails in Android

Before you begin your email activity, you must first understand the operation of Email with Intent. Within the application or outside the application, Intent transports data from one component to another.

You don't have to build an email client from the ground up to send an email from your app; instead, you may utilize one that already exists, such as Android's default Email app, Gmail, Outlook, K-9 Mail, and so on. To accomplish this, we'll need to create an Activity that launches an email client with the appropriate action and data based on an implicit Intent. In this example(later in this blog), we'll use an Intent object to send an email from our app, which will start with existing email clients.

You can also read about, android operating system

Intent Object for Sending Email

The sections below explain the various aspects of our Intent object that are required to send an email.

For Action In Intent Object

The ACTION_SEND action will be used to launch an email client installed on our Android device. The syntax for creating an intent using the ACTION_SEND action is as follows.


Intent emailIntent = new Intent(Intent.ACTION_SEND);

So, we can use the following as per the required action type.

  • ACTION_SENDTO (use it for no attachment) 
  • ACTION_SEND (use it for one attachment) 
  • ACTION_SEND_MULTIPLE (use it for multiple attachments)

For MIME Type In Intent Object

To send an email we need to specify mailto: as URI using the setData() method and MIME type/data type will be set to text/plain using setType() method as follows:



For Extras In Intent Object

Android includes a built-in capability for adding TO, SUBJECT, CC, and TEXT fields which can be attached to the Intent before sending the Intent to the targeted email client. We can include the following extra fields in our Email as shown below.

  • Intent.EXTRA_EMAIL: All "To" recipient email addresses are stored in this string array.
  • Intent.EXTRA_CC: All "CC" recipient email addresses are stored in this string array.
  • Intent.EXTRA_BCC: All "BCC" recipient email addresses are stored in this string array.
  • Intent.EXTRA_SUBJECT: The email subject as a string.
  • Intent.EXTRA_TEXT: A string containing the Email's body.
  • Intent.EXTRA_STREAM: Uri directing attention to the attachment. Instead, this should be an ArrayList containing multiple Uri objects If we are using the ACTION_SEND_MULTIPLE action. 
  • EXTRA_TITLE: When used with an ACTION_CHOOSER, a CharSequence dialog title is sent to the user.

Here's the syntax of how to add extra data to your Intent.


myEmailIntent.putExtra(Intent.EXTRA_EMAIL  , new String[]{"enter Recipient here"});
myEmailIntent.putExtra(Intent.EXTRA_SUBJECT, "type subject here");
myEmailIntent.putExtra(Intent.EXTRA_TEXT   , "content of Message Body");

Now, let us see the implementation part of Sending Emails with a working example given below.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job

Example Application

The example below demonstrates how to use the Intent object to open an Email client and send an email to the specified recipients.

So open up  Android Studio, start an empty activity, give a name to your app(Send Email CN in our case), and let Android do the Gradle syncing.

Now make the activity_main.xml file as per the need of your desired layout.


<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android=""

        android:orientation="vertical" >

            android:textSize="25sp" />

            android:textSize="22sp" />

            android:src="@drawable/my_img" />




    <string name="app_name">Send Email CN</string>
    <string name="coding_ninjas_sending_mail">Coding Ninjas Sending Mail</string>
    <string name="code_studio_presents">~ Code Studio Presents</string>
    <string name="send_this_email">Send this Email</string>


package com.codingninjas.sendemailcn

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

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        val bttn_send_email = findViewById<View>( as Button
        bttn_send_email.setOnClickListener { sendEmail() }

    protected fun sendEmail() {
        Log.i("Send email", "")
        val TO = arrayOf("")
        val CC = arrayOf("")
        val my_email_Intent = Intent(Intent.ACTION_SEND) = Uri.parse("mailto:")
        my_email_Intent.type = "text/plain"
        my_email_Intent.putExtra(Intent.EXTRA_EMAIL, TO)
        my_email_Intent.putExtra(Intent.EXTRA_CC, CC)
        my_email_Intent.putExtra(Intent.EXTRA_SUBJECT, " Enter Your subject")
        my_email_Intent.putExtra(Intent.EXTRA_TEXT, "Email message goes here")
        try {
            startActivity(Intent.createChooser(my_email_Intent, "Send mail using..."))
            Log.i("Finished sending email", "")
        } catch (ex: ActivityNotFoundException) {
                "Please install email client first",

Here we have given sendEmail() method to onCreate() so that in send email method, we can carry out all of the functionalities of our Email that needs to be sent.

Note: You'll need to have an email client installed on your device, such as Gmail (which comes loaded by default with every Android version).

Now run this code in your Android Studio and connect it with your emulator.


Now press the SEND THIS EMAIL button to get a list of all the email clients that have been installed. You can send your Email using one of the email clients from the list. To send my Email, I'll use the Gmail client, which has all of the default fields available, as shown below in the GIF(Output). Here From: will be the default email address associated with your Android smartphone.

You can change either of the default fields before sending your Email to the specified recipients using the send email button.


  1. In Android Studio, how can I open the email app?
     By configuring your email address with Email inbuilt with Email, you can open an email client on an emulator. The Intent will then open and send mail when called.
  2. What is the best way to transmit Intent to another app?
    When you create an intent, you must tell it what action you want it to take. To communicate data from one activity to another, Android employs the action ACTION_SEND. Even across process boundaries, you must define the data as well as its kind(MIME).
  3. What is the difference between an Email and a Gmail?
    Email is the electronic messaging system that allows you to send and receive text, graphics, photos, and videos. On the other hand, Gmail is an email platform that allows you to send and receive emails. We have used Gmail as an email client in this blog since it's preinstalled on our device.

Key Takeaways 

This article taught us how to send emails in Android and its implementation in Android.
You can head over to our Android Development Course on the Coding Ninjas Website to dive deep into Android Development and build future applications.
We hope this article has helped you enhance your knowledge of Email Sending, Intent object, and email clients. If you want to learn more, check out our Programming Fundamentals and Competitive Programming articles. Do upvote this article to help other ninjas grow.

Previous article
Notifications in Android
Next article
Sending SMS in Android
Live masterclass