MailBee.NET Objects 3.1

MailMessage.GetAllRecipients Method 

Gets the EmailAddressCollection object containing the e-mail addresses of all message recipients.

public EmailAddressCollection GetAllRecipients();

Return Value

An EmailAddressCollection object containing the e-mail addresses of all message recipients.

Remarks

The entire collection of the message recipients consists of the e-mail addresses that are contained in the To, Cc and Bcc fields.

Example

This sample loads the message from .EML file and displays the e-mail addresses of all message recipients.

[C#]
using System;
using MailBee;
using MailBee.Mime;

class Sample
{
    static void Main(string[] args)
    {
        // Load the message from file.
        MailMessage msg = new MailMessage();
        msg.LoadMessage(@"C:\Docs\TestMail.eml");

        // Display the e-mail address of each message recipient.
        Console.WriteLine("The message has the following recipient(s):");
        foreach (EmailAddress adr in msg.GetAllRecipients())
        {
            Console.WriteLine(adr.Email);
        }
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.Mime

Module Sample
    Sub Main(ByVal args As String())
        ' Load the message from file.
        Dim msg As New MailMessage
        msg.LoadMessage("C:\Docs\TestMail.eml")

        ' Display the e-mail address of each message recipient.
        Console.WriteLine("The message has the following recipient(s):")
        For Each adr As EmailAddress In msg.GetAllRecipients()
            Console.WriteLine(adr.Email)
        Next
    End Sub
End Module

See Also

MailMessage Class | MailBee.Mime Namespace