flagMessage method
Future<void>
flagMessage(
- MimeMessage message, {
- bool? isSeen,
- bool? isFlagged,
- bool? isAnswered,
- bool? isForwarded,
- bool? isDeleted,
- @Deprecated('use isReadRecieptSent instead') bool? isMdnSent,
- bool? isReadReceiptSent,
Flags the message
with the specified flags.
Set any bool parameter to either true
or false
if you want to change the corresponding flag.
Keep a parameter null
to not change the corresponding flag.
Implementation
Future<void> flagMessage(
MimeMessage message, {
bool? isSeen,
bool? isFlagged,
bool? isAnswered,
bool? isForwarded,
bool? isDeleted,
@Deprecated('use isReadRecieptSent instead') bool? isMdnSent,
bool? isReadReceiptSent,
}) {
if (isSeen != null) {
message.isSeen = isSeen;
}
if (isFlagged != null) {
message.isFlagged = isFlagged;
}
if (isAnswered != null) {
message.isAnswered = isAnswered;
}
if (isForwarded != null) {
message.isForwarded = isForwarded;
}
if (isDeleted != null) {
message.isDeleted = isDeleted;
}
if (isMdnSent != null) {
message.isReadReceiptSent = isMdnSent;
}
if (isReadReceiptSent != null) {
message.isReadReceiptSent = isReadReceiptSent;
}
if (message.flags != null) {
final sequence = MessageSequence.fromMessage(message);
final flags = [...message.flags!];
flags.remove(MessageFlags.recent);
return store(sequence, flags, action: StoreAction.replace);
} else {
throw MailException(this, 'No message flags defined');
}
}