none
Send a mail with system event errors RRS feed

  • Question

  • HI all!!

    I need some help whit this script, the problem is, when I see the mail in outlook not formatted but in txt file the view is okey

    $archivar = Get-EventLog -ComputerName $log -LogName System -EntryType Error -After $FechaAud -ErrorAction Stop | Where-Object {$_.Source -ne 'Service Control Manager'}

    $archivar | out-file c:\milog.txt -Append 

    $send=Get-Content -path c:\milog.txt
    mail($send)

    the problem is get-conten?

    thanks !!

    http://poshcode.com/paste/257/


    • Edited by LaTOO Thursday, May 29, 2014 4:08 PM
    Thursday, May 29, 2014 3:54 PM

Answers

  • $send=Get-Content -path c:\milog.txt | Out-String


    ¯\_(ツ)_/¯

    • Marked as answer by LaTOO Thursday, May 29, 2014 5:05 PM
    Thursday, May 29, 2014 4:20 PM

All replies

  • Try Send-MailMessage and ConvertTo-HTML:

    $archivar = Get-EventLog -ComputerName $log -LogName System -EntryType Error -After $FechaAud -ErrorAction Stop | Where-Object {$_.Source -ne 'Service Control Manager'} | ConvertTo-HTML
    Send-MailMessage -To $emailTo -Subject $subject -From $emailFrom -Body $archivar -BodyAsHTML -SmtpServer $smtpserver -Port $smtport


    I hope this post has helped!

    Thursday, May 29, 2014 4:20 PM
  • $send=Get-Content -path c:\milog.txt | Out-String


    ¯\_(ツ)_/¯

    • Marked as answer by LaTOO Thursday, May 29, 2014 5:05 PM
    Thursday, May 29, 2014 4:20 PM
  • this work !!! thanks
    Thursday, May 29, 2014 5:05 PM