我想在不打开选择器的情况下向多人发送电子邮件,这可能吗?

i`m trying to send an email to multiple people without opening the chooser is that possible?

我想在不打开选择器的情况下向多人发送电子邮件,这可能吗?

我尝试使用数组,但出现错误。

Intent send = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:" + Uri.encode("example@gmail.com") +
        "?subject=" + Uri.encode("the subject") +
        "&body=" + Uri.encode("the body of the message");
Uri uri = Uri.parse(uriText);
send.setData(uri);

startActivity(Intent.createChooser(send, "Send Email..."))

向多个用户发送电子邮件的正确方法是:

科特林:

private fun emailToMultipleUser() {
        val intent = Intent(Intent.ACTION_SEND)
        intent.type = "text/plain"
        intent.setPackage("com.google.android.gm")
        intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("example@gmail.com","chand@gmail.com"))
        intent.putExtra(Intent.EXTRA_SUBJECT, "email subject")
        intent.putExtra(Intent.EXTRA_TEXT, "Hi All ...")

        try {
            startActivity(Intent.createChooser(intent, "send mail"))
        } catch (ex: ActivityNotFoundException) {
            Toast.makeText(this, "No mail app found!!!", Toast.LENGTH_SHORT)
        } catch (ex: Exception) {
            Toast.makeText(this, "Unexpected Error!!!", Toast.LENGTH_SHORT)
        }

    }

Java:

private void  emailToMultipleUser() {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType( "text/plain");
        intent.setPackage("com.google.android.gm");
        intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"example@gmail.com","chand@gmail.com"});
        intent.putExtra(Intent.EXTRA_SUBJECT, "email subject");
        intent.putExtra(Intent.EXTRA_TEXT, "Hi All ...");

        try {
            startActivity(Intent.createChooser(intent, "send mail"));
        } catch (ActivityNotFoundException ex) {
            Toast.makeText(this, "No mail app found!!!", Toast.LENGTH_SHORT);
        } catch (Exception ex) {
            Toast.makeText(this, "Unexpected Error!!!", Toast.LENGTH_SHORT);
        }

    }