appendMessageText method

Future<GenericImapResult> appendMessageText(
  1. String messageText, {
  2. List<String>? flags,
  3. Mailbox? targetMailbox,
  4. String? targetMailboxPath,
  5. DateTime? internalDate,
  6. Duration? responseTimeout,
})

Appends the specified MIME messageText.

When no targetMailbox or targetMailboxPath is specified, then the message will be appended to the currently selected mailbox. You can specify flags such as \Seen or \Draft in the flags parameter. internalDate, when given, is sent as the APPEND command's optional date-time (RFC 3501: [SP date-time] SP literal) so the server records that as the message's INTERNALDATE instead of the time of the append. Specify a responseTimeout when a response is expected within the given time. Compare also the appendMessage and appendMessageBytes methods.

Implementation

Future<GenericImapResult> appendMessageText(
  String messageText, {
  List<String>? flags,
  Mailbox? targetMailbox,
  String? targetMailboxPath,
  DateTime? internalDate,
  Duration? responseTimeout,
}) {
  final numberOfBytes = utf8.encode(messageText).length;
  final cmdText = _buildAppendCommandText(
    targetMailbox,
    targetMailboxPath,
    flags,
    internalDate,
    numberOfBytes,
  );
  final cmd = Command.withContinuation([
    cmdText,
    messageText,
  ], responseTimeout: responseTimeout);

  return sendCommand<GenericImapResult>(
    cmd,
    GenericParser(this, _selectedMailbox),
  );
}