Retrieves a set of mail messages. If no parameters are specified, all mail messages in the mailbox will be retrieved.

Namespace: S22.Pop3
Assembly: S22.Pop3 (in S22.Pop3.dll) Version: 1.1.4653.26443 (1.1.0.0)

Syntax

C#
public MailMessage[] GetMessages(
	uint[] numbers = null,
	FetchOptions options = FetchOptions.Normal,
	bool delete = false
)

Parameters

numbers (Optional)
Type: array<System..::..UInt32>[]()[][]
An array of message numbers of the mail messages to retrieve. If this parameter is null, all mail messages will be retrieved.
options (Optional)
Type: S22.Pop3..::..FetchOptions
A value from the FetchOptions enumeration which allows for fetching selective parts of a mail message.
delete (Optional)
Type: System..::..Boolean
Set this to true to delete the messages on the server after they have been retrieved.

Return Value

An array of initialized instances of the MailMessage class representing the fetched mail messages

Examples

CopyC#
Pop3Client Client = new Pop3Client("pop.gmail.com", 995, "My_Username",
    "My_Password", true, AuthMethod.Login);

/* Download all new messages from the server */
MailMessages messages[] = Client.GetMessages();

/* Print out each message's subject line */
foreach(MailMessage m in messages)
    Console.WriteLine("Subject: " + m.Subject);

Client.Dispose();

Exceptions

ExceptionCondition
S22.Pop3..::..NotAuthenticatedExceptionThrown if the method was called in a non-authenticated state, i.e. before logging into the server with valid credentials.
S22.Pop3..::..BadServerResponseExceptionThrown if the mail messages could not be fetched. The message property of the exception contains the error message returned by the server.

See Also