显示Email Intent中预先填写的收件人地址?

时间:2012-02-13 11:40:33

标签: android email android-intent extra

enter image description here我无法将电子邮件客户端中的TO字段预先填写到此处附加内容中提到的“收件人”地址:

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);   
            }  
        });  

有什么问题?

感谢
斯纳

5 个答案:

答案 0 :(得分:40)

您需要将地址放在数组中:

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

请参阅here

答案 1 :(得分:6)

我有类似的东西及其作品:

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

答案 2 :(得分:2)

使用ACTION_SEND_MULTIPLE时,

你必须为Intent.EXTRA_EMAIL Binyamin Sharet提供一个字符串数组。

如果要求只提供一个地址,则使用Intent.ACTION_SEND。

答案 3 :(得分:0)

试试这个

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

答案 4 :(得分:0)

这对我有用:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] { "someone@gmail.com" });
                        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);