How To Send An Email

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:

Comments 7

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

  2. 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

Leave a Reply

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