How to send emails from my Android application?

前端 未结 21 2667
春和景丽
春和景丽 2020-11-22 00:38

I am developing an application in Android. I don\'t know how to send an email from the application?

21条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 00:54

    Here is the sample working code which opens mail application in android device and auto-filled with To address and Subject in the composing mail.

    protected void sendEmail() {
        Intent intent = new Intent(Intent.ACTION_SENDTO);
        intent.setData(Uri.parse("mailto:feedback@gmail.com"));
        intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        }
    }
    

提交回复
热议问题