Skip to content

Instantly share code, notes, and snippets.

@traktraktrugui
Created October 17, 2013 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save traktraktrugui/7018580 to your computer and use it in GitHub Desktop.
Save traktraktrugui/7018580 to your computer and use it in GitHub Desktop.
EmailHelper
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