Send Email Programmatically in Android

Introduction:

In this tutorial i am going to explain about how to send email programmatically  in Android. In my previous application i have explained about Android Signature Pad ExampleConvert speech to text in android with example code and Android contact picker example.

Implementation of Send Email Programmatically in Android:

In many of the android applications we will be in situation to trigger the mail from our app. So i decided to demonstrate how to Send Email Programmatically in Android in this article.

Below is the complete code of mainactivity.java used to demonstrate how to Send Email Programmatically in Android. In this code i have did following steps.

  1. Get widget reference from xml layout. It contains edittext for toEmailId, mail subject and mail message. And a button to trigger the mail.
  2. For onButtonClick event Create intent with Intent.ACTION_SEND and fill tomailid,mailsuject and mail message as extra arguments to the intent and call it on click event of the button.

 

 

 

 

Now if you run the application you can see the below output.

Output of send email programmatically in android

Output of send email programmatically in android Output of send email programmatically in android Output of send email programmatically in android

Sourcecode of send email programmatically in android

Sourcecode of send email programmatically in android

Leave a Reply

Your email address will not be published. Required fields are marked *