moveMessagesToFlag method
Future<MoveResult>
moveMessagesToFlag(
- MessageSequence sequence,
- MailboxFlag flag, {
- List<
MimeMessage> ? messages,
Moves the specified message sequence
to the folder flagged
with the specified mailbox flag
.
The messages
UIDs will be updated automatically when they are specified.
Throws InvalidArgumentException when the target mailbox with the given
flag
is not found.
Implementation
Future<MoveResult> moveMessagesToFlag(
MessageSequence sequence,
MailboxFlag flag, {
List<MimeMessage>? messages,
}) async {
var boxes = _mailboxes;
if (boxes == null || boxes.isEmpty) {
boxes = await listMailboxes();
if (boxes.isEmpty) {
throw MailException(this, 'No mailboxes defined');
}
}
final target = getMailbox(flag, boxes);
if (target == null) {
throw InvalidArgumentException(
'Move target mailbox with flag $flag not found in $boxes',
);
}
return _incomingLock.synchronized(
() => _incomingMailClient.moveMessages(
sequence,
target,
messages: messages,
),
);
}