Powershell commandline mailing , send mail
- Angelo Schalley
- Dec, 19, 2010
- Exchange, Powershell, Windows-Microsoft
- No Comments
statusmailer.ps1 :
$data can be any data you want to send.
$data = Get-ChildItem “\\10.10.102.249\backup\” | sort-object -property @{Expression={$_.LastWriteTime}; Descending=$true} | format-table LastWriteTime,Length,Name -auto | out-string
$emailFrom = “backup@domain.be”
$emailTo = “user@domain.be”
$subject = “backupverslag LINIX”
$body = $data
$smtpServer = “10.10.10.1”
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
statusmail.cmd :
powershell -command “& ‘c:\tools\statusmailer.ps1’ “