Displaying the To address prefilled in Email Intent?

Smitha picture Smitha · Feb 13, 2012 · Viewed 9.4k times · Source

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

Answer

MByD picture MByD · Feb 13, 2012

You need to put the address in an array:

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

See here.