PowerShell: Script to Send Emails

# Change these values to reflect your liking
$from = "admin@kimconnect.com"
$to = "chuck.norris@kimconnect.com"
$cc = "bruce.lee@kimconnect.com"
$username="kim"
$attachment = "C:\users\$username\Desktop\project1.xlsx"
$subject = "Opening Our First Kung Fu Studio"
$body = "Blah blah... Enough talk. Let's fight!"
$smtpServer = "kimconnect.mail.protection.outlook.com"
$smtpPort = "587"

# This is the Windows' version of sendmail command
Send-MailMessage -From $from -to $to -Cc $cc -Subject $subject -Body $body -SmtpServer $smtpServer -port $smtpPort -UseSsl -Credential (Get-Credential) -Attachments $attachment –DeliveryNotificationOption OnSuccess

Leave a Reply

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