# Can I do this better?

**URL:** <https://forums.powershell.org/t/can-i-do-this-better/2610>\
**Category:** PowerShell Help\
**Created:** [May 22, 2014, 7:13pm UTC](https://forums.powershell.org/t/can-i-do-this-better/2610 "2014-05-22T19:13:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tony-wainwright](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tony-wainwright](https://forums.powershell.org/u/tony-wainwright)\
**Post date:** [May 22, 2014, 7:13pm UTC](https://forums.powershell.org/t/can-i-do-this-better/2610/1 "2014-05-22T19:13:20Z")

</div>

Hi,

Back again ‘re-purposing’ (or as I like to call it ‘screwing it up for my own purposes’) another script in my quest for learning and world domination.

In essence I have a css style assigned to $Style for use with ConvertTo-HTML. The script goes away and collects some info which it puts into an variable called $Var. A separate variable called $Table is created and the following create a $Body variable which is used to as body text for an email.  
`$Body = $Var | Select $Table | ConvertTo-HTML -head $Style`

What I want to do is add some text above the table and format with the predefined $Style.  
I have tried this:  
`$BodyTable = $ItaniumUpdates | Select $Table | ConvertTo-HTML -head $Style
$Body = “Some text here.” + $BodyTable`  
but this doesn’t format the “Some text here.” according to style

How do I add the text to the email before the table and still format it?  
Thanks  
Tony

---

<div class="post-metadata">

**Author:** ![tony-wainwright](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tony-wainwright](https://forums.powershell.org/u/tony-wainwright)\
**Post date:** [May 22, 2014, 7:46pm UTC](https://forums.powershell.org/t/can-i-do-this-better/2610/2 "2014-05-22T19:46:09Z")

</div>

Yes, use the -body parameter  
`$Body = $Var | Select $Table | ConvertTo-HTML -head $Style -boby"Some text here."`  
Love it that I’ve answered my own question!!!

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [May 22, 2014, 11:33pm UTC](https://forums.powershell.org/t/can-i-do-this-better/2610/3 "2014-05-22T23:33:28Z")

</div>

If you wrap your text in an HTML element, like a div, you can apply a class to it and then format that class in your css.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:52pm UTC](https://forums.powershell.org/t/can-i-do-this-better/2610/4 "2024-05-16T20:52:03Z")

</div>

Closed on May 16, 2024, 8:52pm UTC


