|email addressList|
email:= '<abc@gmail.com>,abcd ,<abcef@domail.com>'.
addressList:= MailAddressParser addressesIn:email.
Above code will get me an Ordered collection which will include all the strings, though ‘abcd’ is not a valid email id its still there in collection.
My question is how can i remove Invalid email address which don’t include ‘@’.
addressList do[:ele | " How can i check each item if it includes @ , if not remove it."]
You can take several approaches:
Do exactly what you’ve asked for (deleting from the existing collection)
Or you can generate a new list that includes only the valid elements like Uko proposed. Here you exchange addressList with the new list.
Or you can generate a new list that excludes the invalid elements