Email vis Intent : Email « Network « Android






Email vis Intent

 


package app.test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Intent emailIntent=new Intent(Intent.ACTION_SEND);

        String subject = "Hi!";
        String body = "hello from android....";

        String[] extra = new String[]{"aaa@bbb.com"};
        emailIntent.putExtra(Intent.EXTRA_EMAIL, extra);

        emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        emailIntent.putExtra(Intent.EXTRA_TEXT, body);
        emailIntent.setType("message/rfc822");

        startActivity(emailIntent);
    }
}

//main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

   
  








Related examples in the same category

1.Builds a list of the recipients email addresses each on a different line
2.Is string an Email address
3.Send email
4.isValidEmailAddress: Check the email address is Valid
5.Launch the email intent
6.start Email Intent
7.start Html Email Intent