0% found this document useful (0 votes)
10 views2 pages

Mad 30

The document outlines a practical assignment for developing an email application using XML and Java. It includes the XML layout for the user interface with fields for 'To', 'Subject', and 'Message', as well as a button to send the email. The Java code provided handles the email sending functionality by creating an intent to launch an email client with the entered details.

Uploaded by

moreganu53
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)
10 views2 pages

Mad 30

The document outlines a practical assignment for developing an email application using XML and Java. It includes the XML layout for the user interface with fields for 'To', 'Subject', and 'Message', as well as a button to send the email. The Java code provided handles the email sending functionality by creating an intent to launch an email client with the entered details.

Uploaded by

moreganu53
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/ 2

Name:-Sanskruti wagh Class:-Tycm-mac

Pr no:-30 Batch:-B Roll no:-40


Practical name:-Develop a program to send and receive e-mail
XML File
<?xml version="1.0" encoding="utf-8"?> android:layout_height="48dp"
<LinearLayout android:hint="To"/>
xmlns:android="http://schemas.android.co
m/apk/res/android" <EditText
android:id="@+id/subject"
xmlns:app="http://schemas.android.com/a android:layout_marginTop="20dp"
pk/res-auto" android:layout_gravity="center"
android:layout_width="200dp"
xmlns:tools="http://schemas.android.com/t android:layout_height="48dp"
ools" android:hint="Subject"/>
android:id="@+id/main"
android:layout_gravity="center|top" <EditText
android:orientation="vertical" android:id="@+id/msg"
android:layout_width="300dp" android:layout_width="200dp"
android:layout_height="500dp" android:layout_height="177dp"
android:layout_margin="30dp" android:layout_gravity="center"
tools:context=".MainActivity"> android:layout_marginTop="20dp"
android:hint="Message" />
<TextView
android:layout_gravity="center" <Button
android:textSize="30dp" android:layout_gravity="center"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Draft Email"/> android:onClick="sendEmail"
android:text="send"/>
<EditText
android:id="@+id/to"
android:layout_marginTop="20dp"
android:layout_gravity="center" </LinearLayout>
android:layout_width="200dp"

Java File
package com.example.emailapp;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


EditText to, subject, msg;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
to = findViewById(R.id.to);
subject = findViewById(R.id.subject);
msg = findViewById(R.id.msg);

public void sendEmail(View view) {


Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{to.getText().toString()});
email.putExtra(Intent.EXTRA_SUBJECT, subject.getText().toString());
email.putExtra(Intent.EXTRA_TEXT, msg.getText().toString());
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client:"));
}
}
output

You might also like