如何在Android应用程序中发送电子邮件没有应用程序可以执行此操作

时间:2016-06-16 09:44:37

标签: android

我尝试使用此代码在Android应用中发送电子邮件但我收到此错误

no apps can perform this action

code.java

private void send()
    {
        final String subject2 = subject.getText().toString().trim();
        final String message2 = message.getText().toString().trim();
        final String from2 = from.getText().toString().trim();
        String[] TO = {"recipientadress@gmail.com"};
        Uri uri = Uri.parse("mailto:"+from2)
                .buildUpon()
                .appendQueryParameter("subject", subject2)
                .appendQueryParameter("body", message2)
                .build();
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO, uri);
        emailIntent.setType("text/plain");
        emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));
    }

你能帮助我吗,提前谢谢

1 个答案:

答案 0 :(得分:0)

使用Intent android会尝试寻找发送邮件的应用程序。

或者,您可以尝试使用javax-mail api。

这些链接很有用:

将jar添加到Android Studio:Android Studio: Add jar as library?

使用Javax邮件发送邮件 http://www.tutorialspoint.com/java/java_sending_email.htm