Discover today's file and email with formating

I´ve modified a script that is searching for today’s file.
If the file of today’s exist an e-mail is sent.
But no matter of how i try I cant format the e-mail message with bold headline and with Arial fonts with yellow background color.
Hope someone can guide me further?

Here´s the code:

$Directories = "E:\Source"
$DestDirectory = "E:\Destination"
    
#$OtherDirectory = "E:\Test1"
#$TodaysDirectory = "E:\Test2"
    
 $ThisDay = [datetime]::Today
 $OtherFiles = 0
 $TodaysFiles = 0
 Get-ChildItem $directories |
     ForEach-Object{
         if ($_.Length -eq 0 -and $_.CreationTime.Date -ne $ThisDay){  # What about non-zero length files?
             $OtherFiles++
         Copy-Item "E:\Source\*.txt" -Destination "E:\Destination"
         }
         elseif($_.Length -eq 0 -and $_.CreationTime.Date -eq $ThisDay){  # What about non-zero length files?
             $TodaysFiles++
             Copy-Item "E:\Source\*.txt" -Destination $DestDirectory
         }
     }
    
 if (-not $TodaysFiles){
     Clear-Host
     $body = "No files are found from today, and $OtherFiles old files were found"
     Write-Host $body
     Send-MailMessage -To forename.lastname@domain.com -From server01@domain.com -Subject "Something wrong" -Body $body -SmtpServer smtp1@domain.com
 }
 elseif($OtherFiles){
     Clear-Host
     $body = "found $OtherFiles old files, and $TodaysFiles current files"
     Write-Host $body
     Send-MailMessage -To forename.lastname@domain.com -From server01@domain.com -Subject "Something wrong" -Body $body -SmtpServer smtp1@domain.com 
 }
 else{
     Clear-Host
     $body = "$TodaysFiles are found from today, and $OtherFiles old files were also found"
     Write-Host $body
     Get-ChildItem $DestDirectory | Where {-NOT $_.PSIsContainer} | foreach {$_.fullname} | 
     send-mailmessage -from "Daily Reporting <server01@domain.com>" -to "Forename Lastname <forename.lastname@domain.com>" -subject "Daily Reports" -SmtpServer smtp1@domain.com -Body "Here are the daily research files for your review"

Here´s the source of the script: Powershell check files today in a directory - Microsoft Q&A

First of all you have to use the parameter -BodyAsHtml for the cmdle Send-MailMessage to send formatted emails.

Then you need to provide the html coded content for the -Body parameter. Here you have a starting point for your researches:

@Olaff
Thank´s but at a first look the link seems serious: How To Create An HTML Report With PowerShell How To Create An HTML Report With PowerShell
But the problem is that none of the examples are rendering html in a browser or create a html file that you can view in a Browser.
Here you can test for your self - the first example on that site:

Get-CimInstance -Class Win32_OperatingSystem | Select-object Version,Caption,BuildNumber,Manufacturer |  ConvertTo-Html

PSVersion 5.1.17763.2268
Windows 10 20H2 and Windows Server 2019
Browser: Google Chrome and Windows IE and Edge

So you made it to the second “example” which was really an example of what the cmdlet creates as the author explains. Then they go on to show how to write it to a file. Please actually read the page and learn each step. In the end you won’t want an html file, you’ll just want the html code as the body.

Ok, I forget to pipe the result to | Out-File C:\Test\test.html :upside_down_face:

Do you want to have the output shown in a browser or do you want to send it by mail? If it’s the latter one you don’t need to write it to a file. :wink: