$TS = Get-Date -Format “hh:mm”
Write-Host “($TS)—Email Completion Message—” -foregroundcolor “White”
#create COM object named Outlook
$Outlook = New-Object -ComObject Outlook.Application
#create Outlook MailItem named Mail using CreateItem() method
$Mail = $Outlook.CreateItem(0)
####You Can Add An Attachment Pathway In The Next Line
#$Attachment = “C:\Users\Healthcare.ROC.Repor\DXC Production\Reporting Site - Documents\AWSConnect\qryfltConnect_LastDay.xlsx”
#add properties as desired
$Mail.To = “J.P@GainwellTechnologies.com”
$Mail.Subject = “DB Server Disk Health, Size”
####Add Attachment With Next Line
#$Mail.Attachments.Add($Attachment)
$results2 = $results + $Threshold
$Mail.Body = $results2 # <------- error is here, why does this method not allow a str var ???
#send message
$Mail.Send()
#quit and cleanup
#$Outlook.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Outlook) | Out-Null
$TS = Get-Date -Format “hh:mm”
Write-Host “($TS)—Emailing Completion Message Complete—” -foregroundcolor “White”
OUTPUT :The object does not support this method.
At C:\ROCTeam\PowerShell\DailyDiskThresholdAlert\DiskThreshold.ps1:48 char:1
- $Mail.Body = $results2
-
+ CategoryInfo : OperationStopped: (:) [], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException