fetchMessages method
Future<List<MimeMessage> >
fetchMessages({
- Mailbox? mailbox,
- int count = 20,
- int page = 1,
- FetchPreference fetchPreference = FetchPreference.fullWhenWithinSize,
Loads the specified page
of messages starting at the latest message and going down count
messages.
Specify page
number - by default this is 1, so the first page is downloaded.
Optionally specify the mailbox
in case none has been selected before or if another mailbox/folder should be queried.
Optionally specify the fetchPreference
to define the preferred downloaded scope, defaults to FetchPreference.fullWhenWithinSize
.
By default messages that are within the size bounds as defined in the downloadSizeLimit
in the MailClient
s constructor are donwloaded fully.
Note that the preference cannot be realized on some backends such as POP3 mail servers.
Implementation
Future<List<MimeMessage>> fetchMessages(
{Mailbox? mailbox,
int count = 20,
int page = 1,
FetchPreference fetchPreference =
FetchPreference.fullWhenWithinSize}) async {
mailbox ??= _selectedMailbox;
if (mailbox == null) {
throw StateError('Either specify a mailbox or select a mailbox first');
}
if (mailbox != _selectedMailbox) {
await selectMailbox(mailbox);
}
return _incomingMailClient.fetchMessages(
mailbox: mailbox,
count: count,
page: page,
fetchPreference: fetchPreference);
}