private void ExcludeMailboxes(MailAddressList recipients, string addrStr) { if (string.IsNullOrEmpty(addrStr)) { return; } var addresses = MailboxList.Parse(addrStr); foreach (Mailbox address in addresses) { recipients.Remove(address); } }
private IEnumerable <Mailbox> RemoveMailbox(IEnumerable <Mailbox> source, string email) { email = email.With(_ => _.Trim()); var addresses = new HybridDictionary(); if (!string.IsNullOrEmpty(email)) { foreach (Mailbox mailbox in MailboxList.Parse(email)) { if (!string.IsNullOrEmpty(mailbox.Address)) { addresses.Add(mailbox.Address.ToLower(), mailbox); } } } foreach (Mailbox item in source) { if (addresses.Count == 0 || !addresses.Contains(item.Address.ToLower())) { yield return(item); } } }