I have a powershell script that sends an email with some windows events.
$array contains the events
$array = (Get-WinEvent -FilterXml ([xml](Get-Content C:\SendMail\EventBackup.xml))| Format-List) | out-string
and then in the body of the email, I used to type $Body=$array and my report was like:
TimeCreated : 3/16/2015 2:12:52 AM
ProviderName : Microsoft-Windows-Backup
Id : 14
Message : Backup completed.
TimeCreated : 3/16/2015 2:12:52 AM
ProviderName : Microsoft-Windows-Backup
Id : 4
Message : Backup finished successfully.
TimeCreated : 3/16/2015 1:00:14 AM
ProviderName : Microsoft-Windows-Backup
Id : 1
Message : Backup started.
I have changed the email type to HTML, so I can customize the report, but now the body is like:
TimeCreated : 3/19/2015 2:23:00 AM ProviderName : Microsoft-Windows-Backup Id : 14 Message : Backup completed. TimeCreated : 3/19/2015 2:23:00 AM ProviderName : Microsoft-Windows-Backup Id : 4 Message : Backup finished successfully. TimeCreated : 3/19/2015 1:00:13 AM ProviderName : Microsoft-Windows-Backup Id : 1 Message : Backup started.
All in the same line.
I know it's maybe because this lines:
$emailMessage.IsBodyHtml = $true
$emailMessage.Body = @"$array "@
How can I make it look like before in HTML?