Adds the list of the e-mail addresses specified as EmailAddressCollection to the current collection.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | addresses is a null reference (Nothing in Visual Basic). |
This sample creates a new collection of the e-mail addresses and populates it with some addresses, loads the message from .EML file, and adds this collection to the message recipients collection.
[C#] // To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.Mime; EmailAddressCollection adrs = new EmailAddressCollection(); adrs.AddFromString("User1 <user1@domain.com>"); adrs.Add("user2@domain.com"); MailMessage msg = new MailMessage(); msg.To.Add(adrs); foreach (EmailAddress adr in adrs) { Console.WriteLine(adr.Email); }
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.Mime Dim adrs = New EmailAddressCollection adrs.AddFromString("User1 <user1@domain.com>") adrs.Add("user2@domain.com") Dim msg As New MailMessage msg.To.Add(adrs) For Each adr As EmailAddress In adrs Console.WriteLine(adr.Email) Next
EmailAddressCollection Class | MailBee.Mime Namespace | EmailAddressCollection.Add Overload List | AsString