$body = Get-Content c:\MyFileBody.html
Send-MailMessage -To $_.PrimarySmtpAddress -From
adminscc@mydomain.com -Subject "Migration " -body $body -SmtpServer servXXX -BodyAsHtml
Hi, I am having a similar issue trying to get the html from an attachment to output into the body of an email.
Here is how my script is defined.
# Send Mail Settings
$Recipients = @("ExchangeReporting@contoso.com")
$Sender = "ExchangeReports<NoReply@contoso.com>"
$Subject = "Exchange Hardware Report for $((get-date).ToShortDateString())"
# The body is populated with the content of the HTML file at the end of the script. Any text to include prior to the HTML table
# Should be added here.
#$Body = "This script was executed from " + (Split-Path -parent $MyInvocation.MyCommand.Definition) + " on computer " + $env:computername + "."
$body = Get-Content D:\Scripts\CAS_Hardware.htm
$SMTPServer = "exchange1.contoso.com"
# Send the report as an attachment
Send-MailMessage -To $Recipients -From $Sender -body $body -Subject $Subject -SmtpServer $SMTPServer -Attachments D:\Scripts\Cas_Hardware.htm -BodyAsHtml
I get the email with the attachment, but no body in the email from the htm file.
Any advice?
Thanks Bobby