0

在我的应用程序中,我可以选择通过电子邮件发送文件的 url,它在除 nexus 7 之外的所有设备(仅限操作系统版本 4.2.2)中都能正常工作。当来自nexus 7的邮件时,收件人只收到一个文本。我搜索了很多解决方案,但找不到任何解决方案。下面是我的代码

public static boolean sendEmailLink(Context context, String[] emailTo, String[] emailCC, String[] emailBCC, String subject, String emailBody, String notification) throws ActivityNotFoundException {

    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);

    emailIntent.setType("message/rfc822");

    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailTo);

    emailIntent.putExtra(android.content.Intent.EXTRA_CC, emailCC);

    emailIntent.putExtra(android.content.Intent.EXTRA_BCC, emailBCC);

    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);

    emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(emailBody));

    context.startActivity(Intent.createChooser(emailIntent, notification));

    return true;

} 
4

2 回答 2

1

差别不大,但也许有帮助。你可以试试这个其他 Intent 构造函数

Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + destination));

它对我有用,这是我使用的完整方法:

public static void sendMail(Activity activity, String subject, String body, String destination) {
    Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + destination));
    i.putExtra(Intent.EXTRA_SUBJECT, subject);
    i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
    activity.startActivity(Intent.createChooser(i, "Send mail..."));
}

希望它有效。

于 2013-05-28T12:45:28.387 回答
0

试试这个它对我有用。

Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.putExtra(Intent.EXTRA_SUBJECT,BusinessName);
emailIntent.putExtra(Intent.EXTRA_TEXT,Html.fromHtml(new StringBuilder().append(BusinessName+ "<br /><br />"+ LongDesc+ "<br /><br />"+ "<a href=\""+ ShareURL+ "\">"+ ShareURL+ "</a>").toString()));
startActivity(Intent.createChooser(emailIntent, "Send email..."));
于 2013-04-04T05:05:59.610 回答