Smitha
Smitha

Reputation: 6134

Displaying the To address prefilled in Email Intent?

enter image description hereI am not able to pre fill the TO field in Email client to the "to" address mentioned in the extras here:

EmailImage.setOnClickListener(new OnClickListener() {  
            @Override  
            public void onClick(View v) {  
                 // TODO Auto-generated method stub  
                Intent it = new Intent(Intent.ACTION_SEND_MULTIPLE);   
                it.putExtra(Intent.EXTRA_EMAIL, "[email protected]");   
                it.putExtra(Intent.EXTRA_SUBJECT, "Regarding Policy Info");  
                it.putExtra(Intent.EXTRA_TEXT, "When is my next Premium due");  
                //it.setType("text/plain");   
                it.setType("message/rfc822");  
                startActivity(it);   
            }  
        });  

What is the problem?

Thanks
Sneha

Upvotes: 14

Views: 9522

Answers (5)

Abhilasha Sharma
Abhilasha Sharma

Reputation: 167

This worked for me:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "[email protected]" });
                        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, edt_msg.getText().toString());
                        emailIntent.putExtra(Intent.EXTRA_SUBJECT, edt_subjct.getText().toString());
                        emailIntent.setType("message/rfc822");

                        Uri uri = Uri.parse("file://" + file_img_capt);
                        emailIntent.putExtra(Intent.EXTRA_STREAM, uri);
                        startActivity(emailIntent);

Upvotes: 0

Ajay
Ajay

Reputation: 4926

Try this

Intent sendIntent = new Intent(Intent.ACTION_SEND);
                        sendIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{"","your email"});

Upvotes: 0

Vivek Khandelwal
Vivek Khandelwal

Reputation: 7849

When using ACTION_SEND_MULTIPLE,

You have to provide an array of String for Intent.EXTRA_EMAIL Binyamin Sharet shown you.

If the requirement is to provide only one Address then use Intent.ACTION_SEND.

Upvotes: 2

goodm
goodm

Reputation: 7295

I've got something like this and its works:

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

Upvotes: 7

MByD
MByD

Reputation: 137352

You need to put the address in an array:

it.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"});

See here.

Upvotes: 43

Related Questions