Posts Tagged ‘powershell’

Windows PowerShell Send Email

Tuesday, July 6th, 2010

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)