How to make log contents display with nice formatting in email using powershell?

I'm using the following command to email a backup log file (backup using Amazon AWS ec2 cli sync):

Send-MailMessage -From "" -to "" -Subject "Backup Log for helpdesk on $date" -Body (Get-Content $log) -Smtpserver "" -port "25" -attachment $log

Open in new window

The email is pretty basic. It displays in basic text format. I'd like the results of this backup to display in HTML with a header saying something like "Helpdesk backup results for $date" and then the results below that.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dan CraciunIT ConsultantCommented:
Have you tried inserting HTML formatting?

$header = "<html><head></head><body><h1>Helpdesk backup results for $date</h1><pre>"
$content = (Get-Content $log)
$footer = "</pre></body></html>"
$body = "$header $content $footer"
Send-MailMessage -From "" -to "" -Subject "Backup Log for helpdesk on $date" -Body $body -Smtpserver "" -port "25" -attachment $log

Open in new window

cwhitmore88Author Commented:
When I used your code this is what was in the body of the message:

<html><head></head><body><h1>Helpdesk backup results for 2015-09-29</h1><pre> upload: .\Backup.bat to s3://mybucket/daily/batch/Backup.bat Completed 1 of 2 part(s) with 1 file(s) remaining upload: .\Email.ps1 to s3://mybucket/daily/batch/Email.ps1 </pre></body></html>
Dan CraciunIT ConsultantCommented:
Yup. I forgot the switch :)

Send-MailMessage -From "" -to "" -Subject "Backup Log for helpdesk on $date" -Body $body -BodyAsHtml -Smtpserver "" -port "25" -attachment $log

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cwhitmore88Author Commented:
Ah yea. that works!

One more formatting question. How can I change the font for the header and put background color behind the header and log entries? (maybe alternating colors between each log entry line to make it easier to read?)
Dan CraciunIT ConsultantCommented:
You'll need to define a table and use css for that.
I don't know if the limited HTML interpreter used in email messages supports the :nth-child pseudoclass for alternating colors.

You're better off asking this as a new question with a css tag and provide the expected output from your log.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.