0

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 :"));
bensofter
  • 760
  • 1
  • 14
  • 27

1 Answers1

0

If the above answer mentioned in the comment didn't help you, You can do a simple string replace to remove the < > tags as given below,

String emailsWithTags = TextUtils.join(",", userEmails);
String result = emailsWithTags.replaceAll("<","").replaceAll(">", "");
Intent email = new Intent(Intent.ACTION_SENDTO);
email.setData(Uri.parse("mailto:"+ result));
sanoJ
  • 2,935
  • 2
  • 8
  • 18