$files = get-childitem C:\reports | where name -like "*.png"
$body = @() $attachments = @() foreach($file in $files){ $filename = [system.io.path]::GetFileName($file.FullName) $attachments += $file.fullname $body += "TEST <br /><img src='" + $filename + "'/>TEST <br />"
}
$body = $body | Out-String Send-MailMessage -to someuser@someserver.com -From someotheruser@someserver.com -SmtpServer somemailserver -Subject "Test" -BodyAsHtml $body -Attachments $attachments |
It's a neat little example of generating some HTML in a loop then sending it off using send-mailmessage.