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

Welcome Forums General PowerShell Q&A 3 HTML tables for Email and Only 2nd has correct border

This topic contains 5 replies, has 2 voices, and was last updated by

 
Participant
1 month, 1 week ago.

  • Author
    Posts
  • #122180

    Participant
    Points: 18
    Rank: Member

    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 = ""
    
    $IssuingHTMLReport = $IssuingInfo | ConvertTo-Html -Head $style
    $PolicyHTMLReport = $PolicyInfo | ConvertTo-Html -Head $style
    $RootHTMLReport = $RootInfo | ConvertTo-Html -Head $style
    
    $MessageBody = @"
    
    $IssuingHTMLReport

    $PolicyHTMLReport

    $RootHTMLReport
    "@

    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?

  • #122183

    Participant
    Points: 18
    Rank: Member

    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

  • #122196

    Participant
    Points: 290
    Helping Hand
    Rank: Contributor

    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.
  • #122205

    Participant
    Points: 18
    Rank: Member

    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.

    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 = ""
    
    $IssuingHTMLReport = $IssuingInfo | ConvertTo-Html -Fragment
    $PolicyHTMLReport = $PolicyInfo | ConvertTo-Html -Fragment
    $RootHTMLReport = $RootInfo | ConvertTo-Html -Fragment
    
    $MessageBodyTest = @"
    
    $style
    
    $IssuingHTMLReport
    

    $PolicyHTMLReport

    $RootHTMLReport
    "@
  • #122214

    Participant
    Points: 290
    Helping Hand
    Rank: Contributor

    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. ^^

  • #122220

    Participant
    Points: 18
    Rank: Member

    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. ^^

    Thanks! My original script works fine after updating the the border-width.

You must be logged in to reply to this topic.