Thursday, November 28, 2013

sending mail in android phone to any type of mail account code:-

Layout:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

   
   
    <TextView 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@+string/hello"
    />
</RelativeLayout>

MainActivity are:-


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

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_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);}

   

}





Thank u Friends For seeing code....

No comments:

Post a Comment