Thanks for reaching out to Q&A.
Unfortunately, the Office365 connector will prompt for authentication which is a known limitation. The powershell article that you are refering seems to be archived, I am not sure if it would work as expected or it would be supported. If it works, you can run that script in devops via PowerShell task. However if you are looking for Single sign on approach, then you might want to explore Microsoft Graph API to send mails. You can leverage Azure functions to run the script/code using the Graph API (I have not tried it, you might have to trial and error).