Skip to content

Instantly share code, notes, and snippets.

@benbahrenburg
Last active February 5, 2019 04:16
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 benbahrenburg/0a65d4835aac59aeee11dfbd26235c13 to your computer and use it in GitHub Desktop.
Save benbahrenburg/0a65d4835aac59aeee11dfbd26235c13 to your computer and use it in GitHub Desktop.
MailKit ToMailAddressCollection Extension
public static class MailKitExts
{
public static MailAddressCollection ToMailAddressCollection(this InternetAddressList addressList)
{
if(addressList == null)
{
return new MailAddressCollection();
}
return addressList.Mailboxes.Aggregate(new MailAddressCollection(), (c, r) => { c.Add(new MailAddress(r.Address, r.Name)); return c; });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment