我在数据库中有一个电子邮件地址列表,该列表已提取到数组中。我希望能够通过电子邮件intent
向所有人发送消息。一切正常,但是我发现我的gmail应用程序会退回邮件,因为大多数电子邮件地址的格式都不正确。 Screenshot
如何删除这些标签,以便将电子邮件地址设置为仅显示收件人的逗号分隔符?
private List<String> userEmails = new ArrayList<>();
String emailsWithTags = TextUtils.join(",", userEmails);
String result = emailsWithTags.replaceAll("<","").replaceAll(">", "");
Intent email = new Intent(Intent.ACTION_SENDTO);
email.setData(Uri.parse("mailto:"+ result));
email.putExtra(Intent.EXTRA_TEXT, mMessage.getText().toString());
email.putExtra(Intent.EXTRA_SUBJECT, "Notification ");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
答案 0 :(得分:0)
如果上述注释中提到的答案对您没有帮助,您可以执行简单的字符串替换,以删除下面给出的<
>
标签,
String emailsWithTags = TextUtils.join(",", userEmails);
String result = emailsWithTags.replaceAll("<","").replaceAll(">", "");
Intent email = new Intent(Intent.ACTION_SENDTO);
email.setData(Uri.parse("mailto:"+ result));