Class MapiRecipientCollection

MapiRecipientCollection class

The recipients of an Outlook item.

public class MapiRecipientCollection : Collection<MapiRecipient>

Constructors

NameDescription
MapiRecipientCollection()Initializes a new instance of the MapiRecipientCollection class.

Methods

NameDescription
Add(MapiRecipient)Adds an existing recipient to the end of the collection.
Add(string, string, MapiRecipientType)Adds a recipient.
Add(string, string, string, MapiRecipientType)Adds a recipient with an address of the specified type.
Insert(int, MapiRecipient)Inserts a recipient at the specified position.

Examples

This example adds To, CC and BCC recipients to a message.

[C#]

using (var msg = new MapiMessage("from@domain.com", "to@domain.com", "Report", "The report is attached."))
{
    msg.Recipients.Add("cc@domain.com", "Copy Recipient", MapiRecipientType.MAPI_CC);
    msg.Recipients.Add("bcc@domain.com", "Hidden Recipient", MapiRecipientType.MAPI_BCC);

    foreach (MapiRecipient recipient in msg.Recipients)
    {
        Console.WriteLine($"{recipient.RecipientType}: {recipient.DisplayName} <{recipient.EmailAddress}>");
    }

    msg.Save("report.msg");
}

[Visual Basic]

Using msg = New MapiMessage("from@domain.com", "to@domain.com", "Report", "The report is attached.")
    msg.Recipients.Add("cc@domain.com", "Copy Recipient", MapiRecipientType.MAPI_CC)
    msg.Recipients.Add("bcc@domain.com", "Hidden Recipient", MapiRecipientType.MAPI_BCC)

    For Each recipient As MapiRecipient In msg.Recipients
        Console.WriteLine($"{recipient.RecipientType}: {recipient.DisplayName} <{recipient.EmailAddress}>")
    Next

    msg.Save("report.msg")
End Using

See Also