
$ExchangeServers = (Get-Content C:\Scripts\Input\ExchangeServers.txt).Trim()

 $message.Body = $ExchangeServers | Get-EventLog -newest 300 -logname Application -computername $ExchangeServers | 
 
 where-object -FilterScript {$_.EntryType -ccontains "error"} | 
 Format-Table -Wrap -Property MachineName, Index, TimeGenerated, EntryType, Source, InstanceID, Message -AutoSize


 $now = Get-Date											#Used for timestamps
$date = $now.ToShortDateString()						    #Short date format for email message subject


 # Import Settings.xml config file
 $MyDir = C:\Scripts\input
[xml]$ConfigFile = Get-Content "$MyDir\Settings.xml"

# Email settings from Settings.xml
$smtpsettings = @{
    To = $ConfigFile.Settings.EmailSettings.MailTo
    Cc = $ConfigFile.Settings.EmailSettings.Cc
    From = $ConfigFile.Settings.EmailSettings.MailFrom
    SmtpServer = $ConfigFile.Settings.EmailSettings.SMTPServer
    Subject = "$($ConfigFile.Settings.EmailSettings.Subject) - $now"
    }



Send-MailMessage -From $ConfigFile -to $ConfigFile -Cc $ConfigFile -Subject $ConfigFile `
-Body $message -SmtpServer $ConfigFile -port $ConfigFile -UseSsl `
-Credential (Get-Credential) -Attachments $Attachment

