Last active
February 5, 2019 04:16
-
-
Save benbahrenburg/0a65d4835aac59aeee11dfbd26235c13 to your computer and use it in GitHub Desktop.
MailKit ToMailAddressCollection Extension
This file contains hidden or 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
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