ACTION_SEND force sending with email

前端 未结 9 1905
予麋鹿
予麋鹿 2021-02-15 11:37

every time i create an action for sending an email from my app, it prompts to many options including a QR client...

Is there a way to force sending via email clients onl

9条回答
  •  逝去的感伤
    2021-02-15 12:31

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("text/html");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
    new String[] { "abc@xyz.com" });
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        "Subject of the Mail");
    emailIntent.putExtra( android.content.Intent.EXTRA_TEXT,
                               "This is my sample Mail");
    emailIntent.setType("vnd.android.cursor.dir/email");
    startActivity(Intent.createChooser(emailIntent, "Email:"));
    

    else use this it will shows only the mail clients,

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.setType("message/rfc822");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
    new String[] { "abc@xyz.com" });
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        "Subject of the Mail");
    emailIntent.putExtra( android.content.Intent.EXTRA_TEXT,
                               "This is my sample Mail");
    //emailIntent.setType("vnd.android.cursor.dir/email");
    startActivity(Intent.createChooser(emailIntent, "Email:"));
    

提交回复
热议问题