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 = "[email protected]"
$emailTo = "[email protected]"
$subject = "Subject"
$body = "Some text"
$smtpServer = "mail-server.domain.com"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)

Popularity: 7% [?]

Tags: , ,

Leave a Reply

*