    // Trigger initial mail sync for existing accounts on startup
    QVector<Account> accounts = AccountDao::findAll();
    for (const Account &account : accounts) {
        if (account.type() == AccountType::IMAP) {
            QVector<Folder> folders = FolderDao::findByAccountId(account.id());
            QString inboxFolderId;
            for (const Folder &folder : folders) {
                if (folder.isInbox()) {
                    inboxFolderId = QString::number(folder.id());
                    break;
                }
            }
            if (inboxFolderId.isEmpty() && !folders.isEmpty()) {
                // fallback to first folder
                inboxFolderId = QString::number(folders.first().id());
            }
            if (!inboxFolderId.isEmpty()) {
                qDebug() << "[MainMainWindow] Triggering initial mail sync for account" << account.email() << "folder" << inboxFolderId;
                m_mailService->fetchMails(QString::number(account.id()), inboxFolderId);
            } else {
                qWarning() << "[MainMainWindow] No folders found for account" << account.id();
            }
        }
    }
