How To Send An Email


This is a sample activity which shows How to compose a mail and send it with the default email configured on device. Last topic published on this forum was App Widget.

Underlying Algorithm:

Basic description of algorithm in step by step form:
1.) Create a Project MyEmailDemo.
2.) In Layout we will create two buttons :

(i) To send mail with plain text.
(ii) To send mail with Html Form.

3.) Replace the following code with res/layout/main.xml:




4.) We will use the following code in our activity to compose a email with plain text :




5.) We will use the following code in our activity to compose a email with html body :




6.) Run the application.

Steps to Create:

1.) Open Eclipse. Use the New Project Wizard and select Android Project Give the respective project name i.e. MyEmailDemo. Enter following information:
Project name: MyEmailDemo
Build Target: Android 2.1
Application name: MyEmailDemo
Package name: MyEmailDemo
Create Activity: MyEmailDemo

On Clicking Finish MyEmailDemo code structure is generated with the necessary Android Packages being imported along with MyEmailDemo class will look like following:




You can download the source code of MyEmailDemo by clicking the link.

Output – The final output:

Leave a Comment:

nikhil khatri says July 30, 2011

Thanks it is really very help full

Christopher says September 6, 2011

Another thing

I have download the project but when I am trying to load it at eclipse I have this error “Invalid project Description”


Kalaiselvi G says December 21, 2011

Hai ,

Nice …thanks for this post.Is it possible to send both html and plain text through Intent?

Donna says January 29, 2012

Can you show a screen-shot of the email intent?
Showing the html in email, right before the user hits “send”?

reena says October 19, 2012

Thanks a lot!
It worked like a charm, only i changed setContentView(R.layout.main); to
Thanks again

Meghna says July 7, 2013

Thanks for the clean example… Even this might help, have a look..

Chris Okonkwo says August 25, 2013

Hi there!

Looks like a neat little project. I’ve never done any Android dev before, but I’m currently looking for a solution to an Android email problem. I recently switched to a Galaxy S2 as my phone/mobile office for running my business. But doing so created a problem. I have new order alert emails I receive when customers place orders. The email body includes order detail information (units ordered, color, size, etc) which is sent as one long string. In Outlook on my desktop, I have a sub that runs and parses the string each time Outlook receives a new order email. After the parse, the email body is re-written with the order details on separate lines. It makes the order email muuuuch easier to read. I’d like to do the same thing for my default Android email software. However, I don’t know where to begin. I know that Android is highly customizable. My question is: Is this possible? Judging from your project, it looks do-able. So question is, how do I start? I have Visual Studio to use as an IDE. Where can I get Android SDK etc? Any help would be appreciated. Thanks. OCO

Add Your Reply