Windows PowerShell Send Email

This is posted in heaps of places online (this post is pretty useful – includes details on message format and attachments), so mainly for my own reference:

$emailFrom = "someone@domain.com"
$emailTo = "someone_else@domain.com"
$subject = "Subject"
$body = "Some text"
$smtpServer = "mail-server.domain.com"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)

Tags: , ,

Leave a Reply