Retrieves the set of mail messages with the specified unique identifiers (UIDs) using the
specified fetch-option.
Namespace: S22.ImapAssembly: S22.Imap (in S22.Imap.dll) Version: 3.6.0.0 (3.6.0.0)
Syntax
C# |
---|
IEnumerable<MailMessage> GetMessages( IEnumerable<uint> uids, FetchOptions options, bool seen = true, string mailbox = null ) |
Parameters
- uids
- Type: System.Collections.Generic..::..IEnumerable<(Of <(<'UInt32>)>)>
An enumerable collection of unique identifiers of the mail messages to retrieve.
- options
- Type: S22.Imap..::..FetchOptions
A value from the FetchOptions enumeration which allows for fetching selective parts of a mail message.
- seen (Optional)
- Type: System..::..Boolean
Set this to true to set the \Seen flag for the fetched messages on the server.
- mailbox (Optional)
- Type: System..::..String
The mailbox the messages will be retrieved from. If this parameter is omitted, the value of the DefaultMailbox property is used to determine the mailbox to operate on.
Return Value
An enumerable collection of initialized instances of the MailMessage class representing the fetched mail messages.
Remarks
A unique identifier (UID) is a 32-bit value assigned to each message which uniquely
identifies the message within the respective mailbox. No two messages in a mailbox share
the same UID.
Examples

ImapClient Client = new ImapClient("imap.gmail.com", 993, "My_UsernamMe", "My_Password", true, AuthMethod.Login); // Find all messages that have been sent since June the 1st. IEnumerable<uint> uids = Client.Search( SearchCondition.SentSince( new DateTime(2012, 6, 1) ) ); // Retrieve the messages and print out their subject lines. If any of the messages are multipart // messages, only those parts, that have a content-type of text will be fetched. IEnumerable<MailMessage> messages = Client.GetMessages( uids, FetchOptions.TextOnly ); foreach(MailMessage m in messages) Console.WriteLine("Subject: " + m.Subject); Client.Dispose();
Exceptions
Exception | Condition |
---|---|
System..::..ArgumentNullException | The uids parameter is null. |
S22.Imap..::..BadServerResponseException | The mail messages could not be fetched. The message property of the exception contains the error message returned by the server. |
System..::..ObjectDisposedException | The ImapClient object has been disposed. |
System.IO..::..IOException | There was a failure writing to or reading from the network. |
S22.Imap..::..NotAuthenticatedException | The method was called in non-authenticated state, i.e. before logging in. |