Using Send-MgUserMail as the Send-MailMessage replacement

I have often used the Send-MailMessage cmdlet to test Receive Connectors in Exchange or email reports in scheduled PowerShell scripts. When you try to use the Send-MailMessage cmdlet, it has been showing you this message for quite a while now:

WARNING: The command ‘Send-MailMessage’ is obsolete. This cmdlet does not guarantee secure connections to SMTP servers. While no immediate replacement is available in PowerShell, we recommend you not use Send-MailMessage. See https://aka.ms/SendMailMessage for more information.

In this blog post, I will show you the new way of sending emails using Send-MgUserMail.