You can't use Basic Authentication to send SMTP email with Office365 anymore see https://learn.microsoft.com/en-us/exchange/clients-and-mobile-in-exchange-online/deprecation-of-basic-authentication-exchange-online
That means the .Net SmtpClient can't be used anymore so you need to look at somthing like MailKit https://github.com/jstedfast/MailKit that supports oAuth see https://github.com/jstedfast/MailKit/blob/master/ExchangeOAuth2.md and https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
The other option is to stop using SMTP and switch to using the Graph API https://learn.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=http which is a more secure solution as you can take advantage of the client credentials flow etc in your code and also limit the scope of the target mailboxes you app could send as.