androidemailandroid-intentextra

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, "toaddress@gmail.com");   
                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


Solution

  • You need to put the address in an array:

    it.putExtra(Intent.EXTRA_EMAIL, new String[] {"toaddress@gmail.com"});
    

    See here.