if ($args[0]) {
$file = $args[0]
# todo : test-path $file
$emailFrom = "[email protected]"
$emailTo = "[email protected]"
$subject = "powershell / logs"
# if I want it as an attached file to see newlines
#$body = "log file attached"
# if I want it inline
$body = Get-Content $file
$smtpServer = "my_smtp"
$msg = new-object System.Net.Mail.MailMessage $emailFrom, $emailTo, $subject, $body
# below When I want the log file attached, instead of inline
#$attachment = new-object System.Net.Mail.Attachment $fichier
#$msg.Attachments.Add($attachment)
$client = new-object System.Net.Mail.SmtpClient $smtpServer
$client.Send($msg)
} else { echo "arg missing" }
|