在android中发送邮件

时间:2014-04-21 02:18:00

标签: android email android-intent

我正在尝试以编程方式在android中发送邮件。为此,我写了:

    Intent sendIntent = new Intent(Intent.ACTION_SEND);
    String subject = "Your App "+ context1.getResources().getText(R.string.app_name) +" crashed! Fix it!";
    StringBuilder body = new StringBuilder("Application Name: " + context1.getResources().getText(R.string.app_name));

    body.append('\n').append('\n');
    body.append(errorContent).append('\n').append('\n');
    sendIntent.setType("message/rfc822");
    sendIntent.putExtra(Intent.ACTION_SENDTO,new String[] { "abcxyz@gmail.com" });
    sendIntent.putExtra(Intent.EXTRA_TEXT,body.toString());
    sendIntent.putExtra(Intent.EXTRA_SUBJECT,subject);
    sendIntent.setType("message/rfc822");
    context1.startActivity(sendIntent);

一切正常工作文件邮件正在打开邮件主题和正文,但收件人:未显示,应显示abcxyz@gmail.com

1 个答案:

答案 0 :(得分:2)

你必须使用 sendIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "abcxyz@gmail.com" });