Search code examples
androidandroid-intentemail-client

Calling a mail client when clicking a button


I have a ListView connected to parse server data is coming through parse. when I click single item of the ListView it goes to single item view. there i have a button for email , what i need is when I click that email button and email client should open .with that particular single items email id . email id's are stored in a column in parse database . any one knows please tel how to do this ?

my database is parse server , I need to get emails dynamically from a parse column. each singe item has a different email ... email column name is "email"

*

I used an answer below and edited like this but no receiver email showing

*


edited code using below answer directing to mail client , but no receiver email showing

btn1 = (Button)findViewById(R.id.button5);
            btn1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    String phnoo = object.getString("email");


                    Intent intent = new Intent(Intent.ACTION_SENDTO);
                   intent.setType("message/rfc822");
                    intent.setData(Uri.parse("mailto:"+phnoo));
                    startActivity(intent);

my java code for calling email client

  btn1 = (Button) findViewById(R.id.button5) ;
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String phno="email";

                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri data = Uri.parse("mailto:" +phno);
                intent.setData(data);
                startActivity(intent);
            }
        });

xml code for button

   <Button
            android:id="@+id/button5"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="E-MAIL"

            android:layout_weight="1"
            android:background="#EFEFEF"/>

Solution

  • I think this would help you

    Intent in = new Intent(Intent.ACTION_SEND);
    in.setType("plain/text");
    in.putExtra(Intent.EXTRA_EMAIL, new String[] { "mail id" });
    in.putExtra(Intent.EXTRA_SUBJECT, "subject");
    in.putExtra(Intent.EXTRA_TEXT, "mail body");
    startActivity(Intent.createChooser(in, ""));