(Yes, I know both Send-MailMessage and Net.Mail.SmtpClient exist)
Using
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.