6. juli 2022

Send e-mail from powershell - with TLS !

$body = "tester email fra powershell"

$fromaddress = "someone@somewhere.com"

$toaddress = "receiver@anywhere.com"

$subject = "test mail"

$smtp = "smtp.office365.com"

$port = "587"

Send-MailMessage -from $fromaddress  -to $toaddress -subject $subject -body $body -BodyAsHtml -UseSsl -Credential (Get-Credential)  -smtpServer $smtp -port $port