### Split email addresses

To split email addresses seperated by ; into a list, Regex helps out.
Example split string holding email addresses and add to a listview
' The list of emailaddresses - ensure this string ends with ;
Dim emailaddresses As String = "a@b.c;e@f.g;"
If emailaddresses.EndsWith(";") = False Then emailaddresses = emailaddresses & ";"
' Split
Dim receipients() As String = Regex.Split(";", emailaddresses)
' Add email addresses to the listview
lvwreceipients.Items.AddAll(receipients)
BTW:
To check if an email address is valid, use again Regex, like
Dim isValid as Boolean
Dim s as string = "mywrong#emailaddress.com"
isValid = Regex.IsMatch("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", s)
If isValid = False Then
Log("Error: Invalid email address: " & s)
ws.Alert("Error: Invalid email address: " & CRLF & s)
result = False
End If

Changed: , Category: Strings, File: T6C255M1859.htm, ID: 1859