Hi All,
I am using below script to send mails with multiple attachments but it sending only first file in the folder, need your help.
$runDateTime = Get-Date
$smtp = "smtp.server.com"
$to = "mymailid@com"
$cc = "mymailid@com"
$from = "mymailid@com"
$subject = "HangIssueReport_CL04 - $runDateTime"
$attachmentLocation = "E:\Report\ovc1.2.3.4"
$attachmentLocation = "E:\Report\ovc2.3.4.5"
$attachmentLocation = "E:\Report\ovc3.4.5..6"
$attachmentLocation = "E:\Report\ovc4.5.6.7"
$body = "Hi Team, Good Day, <br><br>"
$body += "This is the <b>lsof report </b> you received at <i>$runDateTime.</i><br><br>"
$body += "Have a great day!<br><br>"
$body += "Thank you <br><br>"
$body += "Test<br>"
$body += "Test "
Send-MailMessage -SmtpServer $smtp -To $to -Cc $cc -From $from -Subject $subject -Body $body -BodyAsHtml -Attachments $attachmentLocation
Write-Host "====== Email sent! ======"
$attachments = @()
foreach($file in $files){
$filename = [system.io.path]::GetFileName($file.FullName)
$attachments += $file.fullname
$body += "TEST <br /><img src='" + $filename + "'/>TEST <br />"