Loading...

Sending Email from Android Application

In this tutorial, you will learn to send an email to someone directly from your android application. To send email from android we will use Intent.ACTION.SEND to call existing email client. If you do not have any email clients in the phone, this email can’t be sent. There must be an error.

Android supports to add CC, BCC, EMAIL, HTML_TEXT, SUBJECT, TEXT, and TITLE. Intent.EXTRA_CC, Intent.EXTRA_BCC, Intent.EXTRA_EMAIL holding the email address, Intent.EXTRA_HTML_TEXT holding HTML formatted text, Intent.EXTRA_TEXT holding subject line of a message, Intent.EXTRA_TEXT is used with ACTION_SEND to supply the literal data to be sent and Intent.EXTRA_TITLE is used with ACTION_CHOOSER.

Related:
How to Get Registered Email Address Programmatically in Android
How to Get the Phone Number Programmatically in Android
How to Use Font Awesome Icons in Android Application

Android Example: How to Send Email in Android Application


Create a new android project and open XML layout file. In XML layout file add three TextViews for subject, email address and message title. EditText for subject input, email address input and message input. Here I have also added a button with send_button id to send message when button is clicked. Following is the complete content of XML layout file.

res/layout/activity_main.xml


Open your app java activity file and define variables for Button, EditText message, email and subject. Link to the XML edit text with findViewById and write the code in onClick listener of the button like below. Following is the complete java code of activity file.

src/SendingEmailFromAndroid.java

Output Screenshots


Android Example: How to Send Email in Android Application

Android Example: How to Send Email in Android Application

Android Example: How to Send Email in Android Application

Now run your Sending Email from Android Application and fill the box of subject email address, body message and click the Send button. After clicking Send button you need to choose the action method from the option like gmail, email, etc which will looks like above screenshot.
Tutorial 3340849867839239321
Home item