SendUsingAccount is not working in Powershell

(Yes, I know both Send-MailMessage and Net.Mail.SmtpClient exist)

Using

https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.sendusingaccount

and

$Outlook = New-Object -ComObject Outlook.Application
foreach ($account in $Outlook.Application.Session.Accounts)
{
if ($account.UserName -eq “accountusername”)
{
$thisaccount=$account
}
}
$Mail = $Outlook.CreateItem(0)
$Mail.SendUsingAccount=$thisaccount
$Mail.To = “destination@emaildomain.com
$Mail.Subject = “a subject”
$Mail.HTMLBody = “i am message<br /><br />”
$Mail.Send()

Im trying to send email from another Exchange account on my Outlook but it is not working. It sends it from the default.

Below solution might work for you.

https://social.technet.microsoft.com/Forums/en-US/20576c13-2077-4df7-90fa-47e635912355/powershell-outlokk-sendusingaccount-not-working?forum=winserverpowershell