0% found this document useful (0 votes)
46 views

Ex - No: 10 Android Application That Send An Email Date

The document describes the steps to develop a simple Android application to send an email. It includes creating a new project, adding layout elements like EditText and Button, and writing Java code to get the input from the layout and send an email intent on button click. The application is tested and sends emails successfully from the inputted recipient, subject, and message body.

Uploaded by

vanitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Ex - No: 10 Android Application That Send An Email Date

The document describes the steps to develop a simple Android application to send an email. It includes creating a new project, adding layout elements like EditText and Button, and writing Java code to get the input from the layout and send an email intent on button click. The application is tested and sends emails successfully from the inputted recipient, subject, and message body.

Uploaded by

vanitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Ex .

No : 10

Date : Android Application that send an Email

Aim :

To develop a Simple Android Application that send an Email.

Procedure :

Step – 1 : Open Android Stdio and then click on File -> New -> New project.

Step – 2 : Then select the Minimum SDK as shown below and click Next.

Step – 3 : Then select the Empty Activity and click Next. 

Step – 4 : Click on app -> res -> layout -> activity_main.xml.

Step – 5 : Click on app -> java -> com.example.exno11 -> MainActivity.

Step – 6 : Display the result.

Step – 7 : Terminate the program.

Program :

Activity_main . xml

         <?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:orientation="vertical" >
<EditText
android:id="@+id/txtTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="To"/>
<EditText
android:id="@+id/txtSub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Subject"/>
<EditText
android:id="@+id/txtMsg"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:hint="Message"/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Send"
android:id="@+id/btnSend"/>
</LinearLayout>

AndroidManifest . xml

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android=http://schemas.android.com/apk/res/android
package="com.tutlane.sendmailexample">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/
<data android:mimeType="message/rfc822"/>
</intent-filter> </activity> </application></manifest>
Output :
ActivityMain . java

package com.tutlane.sendmailexample;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

private EditText eTo;


private EditText eSubject;
private EditText eMsg;
private Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
eTo = (EditText)findViewById(R.id.txtTo);
eSubject = (EditText)findViewById(R.id.txtSub);
eMsg = (EditText)findViewById(R.id.txtMsg);
btn = (Button)findViewById(R.id.btnSend);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL, new String[]{eTo.getText().toString()});
it.putExtra(Intent.EXTRA_SUBJECT,eSubject.getText().toString());
it.putExtra(Intent.EXTRA_TEXT,eMsg.getText());
it.setType("message/rfc822");
startActivity(Intent.createChooser(it,"Choose Mail App"));
}
});
}
}

Result :
Thus a Simple Android Application that send an Email is developed and executed successfully.

You might also like