THIS CONTENT DOWNLOAD SHORTLY

Objective

The main objective of this post is to help you understand how to send Email using inbuilt app in Android.

 

You will get Final Output:

  • android send email using inbuilt app
  • android send email using inbuilt app tutorial
  • android send email using inbuilt app demo
 

Step 1 Create Layouts

Path: res >> layout >> main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
 
    <TextView
        android:id="@+id/textViewPhoneNo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="To : "
        android:textAppearance="?android:attr/textAppearanceLarge" />
 
    <EditText
        android:id="@+id/editTextTo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress" >
 
        <requestFocus />
    </EditText>
 
    <TextView
        android:id="@+id/textViewSubject"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Subject : "
        android:textAppearance="?android:attr/textAppearanceLarge" />
 
    <EditText
        android:id="@+id/editTextSubject"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         >
    </EditText>
 
    <TextView
        android:id="@+id/textViewMessage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Message : "
        android:textAppearance="?android:attr/textAppearanceLarge" />
 
    <EditText
        android:id="@+id/editTextMessage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:inputType="textMultiLine"
        android:lines="5" />
 
    <Button
        android:id="@+id/buttonSend"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Send" />
 
</LinearLayout>
 

Step 2 SendEmailActivity Activity

Full activity class to send an Email. Read the "onClick()" method, it should be self-explanatory.

public class SendEmailActivity extends Activity {
 
Button buttonSend;
EditText textTo;
EditText textSubject;
EditText textMessage;
 
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
 
buttonSend = (Button) findViewById(R.id.buttonSend);
textTo = (EditText) findViewById(R.id.editTextTo);
textSubject = (EditText) findViewById(R.id.editTextSubject);
textMessage = (EditText) findViewById(R.id.editTextMessage);
 
buttonSend.setOnClickListener(new OnClickListener() {
 
@Override
public void onClick(View v) {
 
  String to = textTo.getText().toString();
  String subject = textSubject.getText().toString();
  String message = textMessage.getText().toString();
 
  Intent email = new Intent(Intent.ACTION_SEND);
  email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
  email.putExtra(Intent.EXTRA_SUBJECT, subject);
  email.putExtra(Intent.EXTRA_TEXT, message);
 
  //need this to prompts email client only
  email.setType("message/rfc822");
 
  startActivity(Intent.createChooser(email, "Choose an Email client :"));
 
}
});
}
}

For more details go on following links : I hope you enjoy this tutorial and it would be helpful to you.

Got an Idea of Android App Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Android App Development Company in India.

An entrepreneur who has founded 2 flourishing software firms in 7 years, Tejas is keen to understand everything about gaming - from the business dynamics to awesome designs to gamer psychology. As the founder-CEO of a company that has released some very successful games, he knows a thing or two about gaming. He shares his knowledge through blogs and talks that he gets invited to.

face mask Belial The Demon Headgear Pocket Staff Magic