MailBee.NET Objects 4.0

EmailAddressCollection.Add Method (String, String, String)

Adds the e-mail address (specified as actual e-mail address, display name and remarks parts) to the collection.

public void Add(
   string email,
   string name,
   string remarks
);

Parameters

email
The actual e-mail address (such as JohnDoe@domain.com).
name
The name which is displayed with the actual e-mail address (such as John Doe). If a null reference (Nothing in Visual Basic), no display name will be assigned to the e-mail address.
remarks
The remarks which are displayed with the actual e-mail address (such as ABC Company). If a null reference (Nothing in Visual Basic), no remarks will be assigned to the e-mail address.

Exceptions

Exception Type Condition
MailBeeInvalidArgumentException email is a null reference (Nothing in Visual Basic).

Example

This sample creates a new message and adds a recipient to this message.

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.Mime;

// Create a new MailMessage object.
MailMessage msg = new MailMessage();

// Add a new mail address to the collection.
msg.To.Add("jdoe@domain.com", "John Doe", "ABC Company");
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.Mime

' Create a new MailMessage object.
Dim msg As New MailMessage

' Add a new mail address to the collection.
msg.To.Add("jdoe@domain.com", "John Doe", "ABC Company")

See Also

EmailAddressCollection Class | MailBee.Mime Namespace | EmailAddressCollection.Add Overload List | EmailAddress