Sending HTML Emails via Powershell

Need to email the results of a PowerShell script? Not using Microsoft System Centre Orchestrator? Well the below might help.  

$smtp = "mailserver"

$to = "Recipient Address"

$from = "From Address"

$subject = "Enter Subject Line"

$body = "Dear User$to

$body += "This is a HTML test email HTML email

$body += "Click here to open google

#### Now send the email using > Send-MailMessage

send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml -Priority high

Leave a Reply

Your email address will not be published. Required fields are marked *