Created
October 17, 2013 02:58
-
-
Save traktraktrugui/7018580 to your computer and use it in GitHub Desktop.
EmailHelper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Mail; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
public class EmailHelper | |
{ | |
MailAddressCollection EmailsTo = new MailAddressCollection(); | |
/// <summary> | |
/// Convert string com endereços de email em objetos | |
/// </summary> | |
public MailAddressCollection ParseEmailAddress(string email) | |
{ | |
email = Regex.Replace(email, @"[,]|[;]|[|]", "#"); | |
string[] emails = email.Split('#'); | |
foreach (var e in emails) | |
{ | |
if (e.Length > 5) | |
{ | |
EmailsTo.Add(new MailAddress(e)); | |
} | |
} | |
return EmailsTo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment