Professional Documents
Culture Documents
Mobile App Development Lec 7
Mobile App Development Lec 7
Lecture 7
Send an Email in Android:
Email is messages distributed by electronic means from one system user to one or
more recipients via a network.
Email functionality with intent, Intent is carrying data from one component to another
component with-in the application or outside the application.
We can do this with the help of Intent with action as ACTION_SEND with extra
fields:
email id to which you want to send mail,
the subject of the email and
body of the email.
Basically Intent is a simple message object that is used to communicate
between android components such as activities, use to send the email. This application
basically contains one activity with EditText to take input of email address, subject, and
body of the email from the user and button to send that email.
Send an Email in Android:
Syntax
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL,newString[]{"Recipient"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT,"subject");
emailIntent.putExtra(Intent.EXTRA_TEXT , "Message Body");
Send an Email in Android :
Step 1: Create a new Project
Step 2: Make design in activity.xml file
This application basically contains one activity with EditText to take input of email
address, subject, and body of the email from the user and button to send that email.
Step 3: Code in activity,java file
send=(Button)findViewById(R.id.button1);
Send an Email in Android :
send.setOnClickListener(new OnClickListener(){
public void onClick( )
{
String emailsend = sendto.getText().toString();
String emailsubject = subject.getText().toString();
String emailbody = body.getText().toString();
Intent intent = new Intent(Intent.ACTION_SEND);