Removes the specified e-mail address from the collection.
If the specified e-mail address appears multiple times in the collection, all such entries will be removed.
To remove the e-mail address from the collection by the index, the developer should use RemoveAt method.
| Exception Type | Condition |
|---|---|
| MailBeeInvalidArgumentException | address is a null reference (Nothing in Visual Basic). |
This sample adds some e-mail addresses into To: field and then removes one of them.
[C#] // To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.Mime; MailMessage msg = new MailMessage(); msg.To.Add("user1@domain.com"); msg.To.Add("user2@domain.com", "User 2"); msg.To.Add("user3@domain.com", null, "User 3"); Console.WriteLine(msg.To.ToString()); msg.To.Remove("user2@domain.com"); Console.WriteLine(msg.To.ToString());
[Visual Basic] ' To use the code below, import MailBee namespaces at the top of your code. Imports MailBee Imports MailBee.Mime Dim msg As New MailMessage msg.To.Add("user1@domain.com") msg.To.Add("user2@domain.com", "User 2") msg.To.Add("user3@domain.com", Nothing, "User 3") Console.WriteLine(msg.To.ToString()) msg.To.Remove("user2@domain.com") Console.WriteLine(msg.To.ToString())
EmailAddressCollection Class | MailBee.Mime Namespace | RemoveAt