Managing personal Outlook.com account settings, security, and privacy
Hi, I'm John! I will help you with this.
If you did not request the code, do not use it and do not click any links in the email.
Can you share the sender email address so we can check if it is really from Microsoft? Please blur any sensitive info such as your email address. This forum is public.
Sometimes this can happen if someone accidentally entered your email while trying to sign in, or someone knows your account credentials and is trying to access the account. Have you already changed the password for that account?
If you haven't already, I would recommend checking the recent activity page and changing the password if you have not done so already. Also make sure two-step verification is enabled.
You can check account activity here: https://account.live.com/Activity
"How to help keep your Microsoft account secure" https://support.microsoft.com/account-billing/how-to-help-keep-your-microsoft-account-secure-628538c2-7006-33bb-5ef4-c917657362b9