I have a list of email addresses on my database that I fetched into an array. I want to be able to send messages to all of them with email intent
. Everything worked fine but I discovered that my gmail app was bouncing the messages because most of the email addresses were not properly formatted. Screenshot
How do I remove those tags such that the email addresses would be formatted to show just comma separator for the recipients?
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 :"));