Using Android Intent.ACTION_SEND for sending email

前端 未结 17 1301
野趣味
野趣味 2020-11-29 23:07

I\'m using Intent.ACTION_SEND to send an email. However, when I call the intent it is showing choices to send a message, send an email, and also to

17条回答
  •  醉话见心
    2020-11-29 23:50

    This will open only the Email app installed in your android phone.

            Intent intent = new Intent(Intent.ACTION_SENDTO);
            intent.setData(Uri.parse("mailto:"));
            intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"example@gmail.com"});
            intent.putExtra(Intent.EXTRA_SUBJECT, "email subject");
            intent.putExtra(Intent.EXTRA_TEXT, "message body");
    
            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);
            }
    

提交回复
热议问题