Hi @Andreas Thank you for reaching out to us.
I understood your scenario, for the similar issue there is an approach documented in this article https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/microsoft-365-password-expiration-notification-email-solution/ba-p/2796353
Test the script thoroughly before implementing it in production environment.
Let me know if you have any questions.
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.