Help emailing formatted HTML - Please

This topic contains 3 replies, has 2 voices, and was last updated by  Nick Jaggers 4 years, 1 month ago.

  • Author
  • #16344

    Nick Jaggers

    Having problems emailing an HTML report (script attached) I can run script and outputs a nice formatted table with conditioning as an HTML page, but either missing a trick sending as an email (works without the formatting) or I am using technique that is not really compatible.
    I'm very much still learning so any help would be much appreciated.


  • #16347

    Martin Nielsen

    In the html file you generate, you attach the head before outputting it to a file. When you email it you only send the body.

    You've got to

    $body = ConvertTo-Html -Head $Head -PostContent "$(get-date)" -Body $body | Out-String
    send-mailmessage @Smtpsettings -Body $body -BodyAsHtml
  • #16354

    Nick Jaggers

    Thanks Martin, will test it tomorrow, cheers!

  • #16368

    Nick Jaggers

    Worked a treat, many thanks!

You must be logged in to reply to this topic.