deleteMailbox method

Future<void> deleteMailbox({
  1. required String folderPath,
  2. required MailboxType type,
})

Delete a mailbox

Implementation

Future<void> deleteMailbox({
  required String folderPath,
  required MailboxType type,
}) async {
  _logger.fine('Deleting mailbox: $folderPath');

  final address = MailboxAddress(
    ownerId: host.id,
    folderPath: folderPath,
    type: type,
  );

  final request = DeleteMailboxRequest(address: address);

  final response = await _sendRequest(request);
  if (!response.success) {
    throw MailboxManagementError(
      response.errorMessage ?? 'Failed to delete mailbox',
    );
  }

  _logger.info('Deleted mailbox: ${address.fullPath}');
}