我将如何在Android中发送邮件?

时间:2017-05-29 15:08:04

标签: java android javamail

我尝试使用意图发送邮件,但它没有用。

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{adres});
    intent.putExtra(Intent.EXTRA_SUBJECT, konu);
    intent.putExtra(Intent.EXTRA_TEXT, icerik);
    startActivity(intent);

2 个答案:

答案 0 :(得分:0)

试试这个:

Intent email = new Intent(Intent.ACTION_SEND);  
              email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});  
              email.putExtra(Intent.EXTRA_SUBJECT, subject);  
              email.putExtra(Intent.EXTRA_TEXT, message);  

              //need this to prompts email client only  
              email.setType("message/rfc822");  

              startActivity(Intent.createChooser(email, "Choose an Email client :"));  

答案 1 :(得分:0)

尝试添加以下行:

startActivity(Intent.createChooser(intent, "Send email with: "));