skip to Main Content

enter image description hereenter image description hereI have a script that takes bugs from TFS and builds a table with the relevant titles.
The script reads from XML 2 query IDs, creates 2 tables, and then sends them as an email.
The script is working but I need to add a space between the tables, currently, they stick together. I tried many things like br and div but nothing helped.
I will copy only the relevant code for the tables. I don’t want to change the table or improve it, so help me to add a space between the tables

$HtmlTable = "<table border='1' align='Left' cellpadding='2' cellspacing='0' style='color:black;font-family:arial,helvetica,sans-serif;text-align:left;'>
                <tr style ='font-size:14px;font-weight: normal;background: #FFFFFF'>
                <th align=left><b>Version</b></th>
                <th align=left><b>Severity</b></th>
                <th align=left><b>Title</b></th>
                <th align=left><b>State</b></th>
                </tr>"
$HtmlTable += "<tr style='font-size:14px;background-color:#FFFFFF'>
    <td>" + $CloudVersion + "</td>
    <td>" + $Bug_Severity + "</td>
    <td>" + $Bug_Title + "</td>
    <td>" + $Bug_State + "</td>
    </tr>" 

$HtmlTable += "</table>"

All the above is a function that is called twice, $Htmls contains the 2 tables

$Htmls += $HtmlTable

This function displays the tables

function Print ($Htmls) {
    $outlook = [Runtime.InteropServices.Marshal]::GetActiveObject('Outlook.Application')
    $Mail = $Outlook.CreateItem(0)
    foreach ($html in $Htmls) {
    $mail.HTMLBody += $html
    }
    $Mail.Display()
} 

2

Answers


  1. you could have some thing like this, wrap table to a flex div with spacing to
    make it look neat.

    $HtmlTable = "<div style="display: flex; padding: 1rem 0.5rem"> <table border='1' align='Left' cellpadding='2' cellspacing='0' style='color:black;font-family:arial,helvetica,sans-serif;text-align:left;'>
                <tr style ='font-size:14px;font-weight: normal;background: #FFFFFF'>
                <th align=left><b>Version</b></th>
                <th align=left><b>Severity</b></th>
                <th align=left><b>Title</b></th>
                <th align=left><b>State</b></th>
                </tr>"
    $HtmlTable += "<tr style='font-size:14px;background-color:#FFFFFF'>
    <td>" + $CloudVersion + "</td>
    <td>" + $Bug_Severity + "</td>
    <td>" + $Bug_Title + "</td>
    <td>" + $Bug_State + "</td>
    </tr>" 
    
    $HtmlTable += "</table></div>"
    

    please tell me if that worked or not.

    Login or Signup to reply.
  2. So to create space between the table you can use margin. In the below code I have add margin around the table.

    You can copy below code and try it on your project, hope it helped thank you.

    $HtmlTable = "<table border='1' align='Left' cellpadding='2' cellspacing='0' style='color:black;font-family:arial,helvetica,sans-serif;text-align:left; margin: 15px;'>
                    <tr style ='font-size:14px;font-weight: normal;background: #FFFFFF'>
                    <th align=left><b>Version</b></th>
                    <th align=left><b>Severity</b></th>
                    <th align=left style="min-width: 70vh;"><b>Title</b></th>
                    <th align=left><b>State</b></th>
                    </tr>"
    $HtmlTable += "<tr style='font-size:14px;background-color:#FFFFFF'>
        <td>" + $CloudVersion + "</td>
        <td>" + $Bug_Severity + "</td>
        <td>" + $Bug_Title + "</td>
        <td>" + $Bug_State + "</td>
        </tr>" 
    
    $HtmlTable += "</table>"
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search