3 HTML tables for Email and Only 2nd has correct border

I am struggling with getting a consistent border between 3 tables that I am converting to HTML. Am I doing something wrong? I want a “double” border for all 3 of these tables.

$style = "<style>BODY{font-family: Calibri; font-size: 10pt;}"
$style = $style + "TABLE{border-width: 1px; border-style: double; border-color: black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; font-family: Verdana; font-weight: bold; font-size: 10pt; color:white; background: #003C68; padding: 5px;}"
$style = $style + "TD{border: 1px solid black; padding: 5px;}"
$style = $style + "</style>"

$IssuingHTMLReport = $IssuingInfo | ConvertTo-Html -Head $style
$PolicyHTMLReport = $PolicyInfo | ConvertTo-Html -Head $style
$RootHTMLReport = $RootInfo | ConvertTo-Html -Head $style

$MessageBody = @"
<br>
$IssuingHTMLReport
<br>
<br>
$PolicyHTMLReport
<br>
<br>
$RootHTMLReport
<br>
"@

I know that when saved to Outlook it sometimes formats HTML differently than a web browser would. However, when I just save the main output with the 3 reports ($MessageBody) to an html file, it still does not have the double border. How do I get the border looking consistent for all 3 tables?

It looks like my style and MessageBody are altered when posting. It is basically the same, except I have “style” and “/style” at the beginning and end and then “br” for the new lines in $MessageBody

Yeah, ConvertTo-Html makes a complete HTML document by default. I’m sure trying to have more than one HTML doc in an email is confusing Outlook no end, as it would with most browsers.

What you need to do, rather than supplying -Head for everything is:

  1. Construct your header
  2. Use ConvertTo-Html -Fragment to ensure that it only generates the table, not the surrounding HTML doc
  3. Manually build a basic HTML document framework. Put the tables in the body tags, your style information in head tags, etc., wrap it all up in a html tag all in your here-string.

[quote quote=122196]Yeah, ConvertTo-Html makes a complete HTML document by default. I’m sure trying to have more than one HTML doc in an email is confusing Outlook no end, as it would with most browsers.

What you need to do, rather than supplying -Head for everything is:

  1. Construct your header
  2. Use ConvertTo-Html -Fragment to ensure that it only generates the table, not the surrounding HTML doc
  3. Manually build a basic HTML document framework. Put the tables in the body tags, your style information in head tags, etc., wrap it all up in a html tag all in your here-string.
[/quote] Tried doing this and the HTML file is just showing a solid line for the border. Is there something wrong in my style tag?
$style = "<style>BODY{font-family: Calibri; font-size: 10pt;}"
$style = $style + "TABLE{border-width: 1px; border-style: double; border-color: black; border-collapse: collapse;}"
$style = $style + "TH{border: 1px solid black; font-family: Verdana; font-weight: bold; font-size: 10pt; color:white; background: #003C68; padding: 5px;}"
$style = $style + "TD{border: 1px solid black; padding: 5px;}"
$style = $style + "</style>"

$IssuingHTMLReport = $IssuingInfo | ConvertTo-Html -Fragment
$PolicyHTMLReport = $PolicyInfo | ConvertTo-Html -Fragment
$RootHTMLReport = $RootInfo | ConvertTo-Html -Fragment

$MessageBodyTest = @"
<HTML>
<head>$style</head>
<body>
$IssuingHTMLReport
<br>
<br>
$PolicyHTMLReport
<br>
<br>
$RootHTMLReport
<br>
</body>
</HTML>
"@

Yeah, sort of. A double border style can only take effect within the limitations of the specified border width. A border specified at 1px has no further subdivisions available to use, so it will look the same as solid; you can’t subdivide a single pixel when drawing a border.

The minimum width of a border for double to have a noticeable effect is 3px; larger numbers result in a best-effort attempt to subdivide the value in three. For example, a 5px width would have two visible lines at 2px and a 1px gap between them.

It’s been a while since I toyed with borders like this, so I didn’t notice it at first, sorry. ^^

[quote quote=122214]Yeah, sort of. A double border style can only take effect within the limitations of the specified border width. A border specified at 1px has no further subdivisions available to use, so it will look the same as solid; you can’t subdivide a single pixel when drawing a border.

The minimum width of a border for double to have a noticeable effect is 3px; larger numbers result in a best-effort attempt to subdivide the value in three. For example, a 5px width would have two visible lines at 2px and a 1px gap between them.

It’s been a while since I toyed with borders like this, so I didn’t notice it at first, sorry. ^^

[/quote]
Thanks! My original script works fine after updating the the border-width.